ajax call from pure javascript not returning response from remote php file(no jQuery)

mo jo

New Member
I am using pure javascript to make an ajax call to a PHP file which is residing in the remote server. But it is not returning the response.The page which is making the ajax call is in my localhost.Here is the ajax call code:\[code\]if (window.XMLHttpRequest) { xmlhttp=new XMLHttpRequest(); } else{ xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.onreadystatechange=function(){ if (xmlhttp.readyState==4 && xmlhttp.status==200){ if(xmlhttp.responseText == 1){ document.getElementById("update").innerHTML = "Update Successfull"; } } } //https://flo2go-airteliptv.rhcloud.com xmlhttp.open("POST",'https://xyz.com/purchasereturn.php',true); xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); xmlhttp.send("setflag=1");\[/code\]The PHP code on the remote server is this:\[code\]<?phpheader('content-type: application/javascript; charset=utf-8'); $purchasevalue = http://stackoverflow.com/questions/15601191/0; while($purchasevalue != 1){ $query ="SELECT * FROM purchase WHERE purchase_id = 1"; $result = mysql_query($query); while($row = mysql_fetch_array($result)){ $purchasevalue = http://stackoverflow.com/questions/15601191/$row['purchase_flag']; } } //$purchasevalue = "http://stackoverflow.com/questions/15601191/{purchase:$purchasevalue}"; echo $purchasevalue;?>\[/code\]How can I get the response ? Please help.
 
Back
Top