I am not getting response while fetching result from my code using AJAX. while sending parameters to file my code is working good… that is, sending parameters to file , as I have checked using alert msg..
but my php file is not showing any response.
AJAX CODE.
function viewsg(){
document.getElementById('sgwaitingmsg').innerHTML = "Just a second...";
var childid = encodeURIComponent(document.getElementById('childsgselect').value);
var parameters ='childid=' + childid;
http.open('POST', 'fetchsg.php', true);
http.send(parameters);
//alert(parameters);
http.onreadystatechange = function(){
if (xmlhttp.readyState==4 && xmlhttp.status==200 )
{
document.getElementById("sgwaitingmsg").innerHTML=xmlhttp.responseText;
}
}
}
PHP CODE.
<?php
//$_REQUEST["childid"];
//$_REQUEST["nocache"];
echo $_REQUEST["childid"];
?>
HTML CODE.
<label id="sgwaitingmsg"></label>
<select id="childsgselect" onchange="viewsg()" >
<option value="">Select Child</option>
<?php while($result=mysql_fetch_assoc($child)){print '<option value="'.$result["snum"].'">'.$result["sfname"].'</option>'; }?>
</select>
$_REQUEST["childid"];does not do anything. tryinstead
and you have syntax error in your code
should be
Try this one http://sandbox.phpcode.eu/g/904ed/10
is fully working script. You’ll have to go through