The following code is working fine in Google Chrome but not in Firefox. I can't make a request and can't receive a response. I don't know what the problem is?
This is my Javascript code.
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
// alert(str);
xmlhttp.open("GET","server url/folder/file.php?q="+"string",true,"user","password");
alert();
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
alert("response");
alert(xmlhttp.responseText);
var string=xmlhttp.responseText;
}
}
xmlhttp.send();
This is my server script which would respond.
<?php
header('Access-Control-Allow-Origin: *');
$q=$_GET["q"];
echo $q;
?>