Get php function value from javascript -


allow me preface saying did on other answers, still uncertain how execute it.

here problem:

i have .txt file reading , parsing meaning of name (i know, db better, given). wish fetch return value of php function javascript function. how go doing this?

php code:

function populatemeaning() {     $meanings = fopen("meanings.txt", "r") or die("unable open file");     $meaning = "";      $selectoption = $_post['allnames'];      while(!feof($meanings)) {         $selectoption = strtoupper($selectoption);         $line = fgets($meanings);          if(strpos($line,$selectoption ) !== false) {             $meaning = substr($line, strpos(0, ' '), strlen($line));         }     }      return $meaning; } 

javascript function in question:

function meaning(){      document.getelementbyid("meaning").innerhtml = "hello"; } 

so have div element titled "meaning" , replace it's inner html value. string "hello" placeholder make sure js called correctly.

jquery ajax in short, front (javascript) back-end (php) value http://www.w3schools.com/jquery/ajax_ajax.asp or google jquery ajax


Comments

Popular posts from this blog

java - SSE Emitter : Manage timeouts and complete() -

jquery - uncaught exception: DataTables Editor - remote hosting of code not allowed -

java - How to resolve error - package com.squareup.okhttp3 doesn't exist? -