How to send a Javascript/Ajax variable to a php page using AJAX -
function rungetiperfspeedajax(speedvar, actualip) { var xmlhttp = getajaxobject(); xmlhttp.onreadystatechange = function () { if (xmlhttp.readystate == 4 && xmlhttp.status == 200) { processiperfrequest(xmlhttp.responsetext, speedvar); } } xmlhttp.open('get', 'lib/getiperfspeed.php', true); xmlhttp.setrequestheader('content-type', 'application/x-www-form-urlencoded'); xmlhttp.send(); } function processiperfrequest(response, speedvar) { alert("proccess"); document.getelementbyid(speedvar).style.display = 'none'; document.getelementbyid('displayspeedtest').style.display = 'block'; document.getelementbyid('displayspeedtest').innerhtml = response; }
getajaxobject()
not included standard. making onclick javascript call calls rungetiperfspeedajax
. works if hard set ip in "lib/getiperfspeed.php". cannot seem pass actualip
"lib/getiperfspeed.php". tried 'lib/getiperfspeed.php'+actualip
attempt pass , access through post.
all appreciated.
if want pass ip value have add key
function rungetiperfspeedajax(speedvar, actualip) { var xmlhttp = getajaxobject(); xmlhttp.onreadystatechange = function () { if (xmlhttp.readystate == 4 && xmlhttp.status == 200) { processiperfrequest(xmlhttp.responsetext, speedvar); } } xmlhttp.open('get', 'lib/getiperfspeed.php?ip='+actualip, true); // missing in code '&ip='+actualip xmlhttp.setrequestheader('content-type', 'application/x-www-form-urlencoded'); xmlhttp.send(); } function processiperfrequest(response, speedvar) { alert("proccess"); document.getelementbyid(speedvar).style.display = 'none'; document.getelementbyid('displayspeedtest').style.display = 'block'; document.getelementbyid('displayspeedtest').innerhtml = response; }
so in getiperfspeed.php
actualip
ip
$_get['ip']
if need pass actualip post need change ajax post.
Comments
Post a Comment