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;
}
NOTE: getAjaxObject() is not included as it is just standard. I am making
an onclick javascript call that calls runGetIperfSpeedAjax. This all works
properly if I hard set the IP in lib/getIperfSpeed.php. But I cannot seem
to pass the actualIp to lib/getIperfSpeed.php. I tried
'lib/getIperfSpeed.php'+actualIp to attempt to pass it and access it
through post.
All help is appreciated.
No comments:
Post a Comment