I am trying to hit a third party URL to get the XML response and to show the reposne into my webpage.
I get a proper response with status as 200 and readystate as 4 in IE and Safari browsers.
But In FF3.5 and Crome i get XMLHTTPRequest status as 0 and reponseText comes as a blank string. I tried many options writing the normal XMLHTTPRequest Ajax code as well as using Prototype 1.5 version js file for this ajax request, but still the status and reponseText in FF 3.5 remains the same as 0 and blank string.
Any help how to resolve this issue or what exactly is causing this issue would be greatly appreciated.
I had also tried to execute my code locally as well as deploying to webserver still the repsonse in FF is same.
Below is my code snippet
<script type="text/javascript" src="prototype_ajax.js"></script>
<script type="text/javascript" language="javascript">
new Ajax.Request("I place my URL Here", {
method: 'get',
onSuccess : function(transport){
var resultDoc = transport.responseText;
var rootObj = loadXML(resultDoc);
},
onFailure : function(transport){
alert(' On Failure '+transport)
}
});
function loadXML(xmlFile) {
var xmlDocElement =null;
var xmlDoc = null;
if (window.ActiveXObject) {
try {
// code for IE
xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
xmlDoc.async=false;
xmlDoc.loadXML(xmlFile);
} catch (e) {
alert("inside catch::"+e.message);
}
} else {
// code for Mozilla, Firefox, Opera, etc.
parser=new DOMParser();
xmlDoc=parser.parseFromString(xmlFile,"text/xml");
//xmlDocElement=xmlDoc.documentElement;
}
//alert('loadXML value '+xmlDoc)
return xmlDoc;
}
</script>
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…