jquery - pass xmlhttp.responseText data to php variable -
i have jquery brinds text page through ajax , displays text in div want pass data php variable how can ?
my jquery code is
<script type="text/javascript"> var xmlhttp = null; window.onload = function() { xmlhttp = new xmlhttprequest(); xmlhttp.open("get", "abc.php", true); xmlhttp.onreadystatechange = oncallback; xmlhttp.setrequestheader('content-type','application/x-www-form-urlencoded'); xmlhttp.send(null); } function oncallback() { if (xmlhttp.readystate == 4) { if (xmlhttp.status == 200) { alert(xmlhttp.responsetext); document.getelementbyid('show').innerhtml=xmlhttp.responsetext; } } } </script> here want save xmlhttp.responsetexrt in php variable in same file how can ?
javascript executed on browser, , php executed in web server. can not directly pass values javascript php.
therefore, need make ajax call (post) javascript web server sends xmlhttp.responsetext, , write php code in server store value database.
Comments
Post a Comment