I’m using the following code to make a call to a REST API using JavaScript. This code works fine with IE but hangs at send method with Firefox 9.0.1. I believe IE is not cashing the previous response.
I have tried debugging with Firebug, but it’s not helping. XMLHttpRequest object, which is for Firefox, is created successfully and it goes through all the code, but no response.
<script language="javascript" type="text/javascript">
function processRequest() {
var signedURI = "http://api.saaspose.com/v1.0/storage/disc?appSID=myappSID&signature=mySignature";
var xmlhttp = null;
if (window.XMLHttpRequest) {
xmlhttp = new XMLHttpRequest();
if (typeof xmlhttp.overrideMimeType != 'undefined') {
xmlhttp.overrideMimeType('text/xml');
}
} else if (window.ActiveXObject) {
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
} else {
alert('Not supported!');
}
xmlhttp.open('GET', signedURI, true);
xmlhttp.onreadystatechange = function () {
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
alert(xmlhttp.responseText);
} else {
//alert("ready state : " + xmlhttp.readyState.toString() + " status : " + xmlhttp.status.toString());
}
};
xmlhttp.send(null);
}
</script>
Any idea why is this issue occurring with Firefox but not with IE?
The team had to resolve this issue by adding JSONP support to the WCF services and then using the jQuery at the client end like this:
Thank you all for your comments.