Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The PHP function cannot be called in the way that you have illustrated above. However you can call a PHP script using AJAX, code is as shown below. Also you can find a simple example <a href="http://tallymobile.com/test3.html" rel="nofollow">here</a>. Let me know if you need further clarification</p> <p><strong>Using Jquery</strong></p> <pre><code>&lt;script type="text/javascript" src="./jquery-1.4.2.js"&gt;&lt;/script&gt; &lt;script type="text/javascript"&gt; function compute() { var params="session=123"; $.post('myphpscript.php',params,function(data){ alert(data);//for testing if data is being fetched var myObject = eval('(' + data + ')'); document.getElementById("result").value=myObject(addend_1,addend_2); }); } &lt;/script&gt; </code></pre> <p><strong>Barebones Javascript Alternative</strong></p> <pre><code> &lt;script type="text/javascript"&gt; function compute() { var params="session=123" var xmlHttp; var addend_1=document.getElementById("par_1").value; var addend_2=document.getElementById("par_2").value; try { xmlHttp = new XMLHttpRequest(); } catch (e) { try { xmlHttp = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try { xmlHttp = new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) { alert("No Ajax for YOU!"); return false; } } } xmlHttp.onreadystatechange = function() { if (xmlHttp.readyState == 4) { ret_value=xmlHttp.responseText; var myObject = eval('(' + ret_value + ')'); document.getElementById("result").value=myObject(addend_1,addend_2); } } xmlHttp.open("POST", "http://yoururl/getjs.php", true); xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); xmlHttp.setRequestHeader("Content-length", params.length); xmlHttp.setRequestHeader("Connection", "close"); xmlHttp.send(params); } &lt;/script&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload