I have following script
$.ajax({
type:"GET",
url:"views/jquery/js/private/visual_constructor/proxy.php",
data:null,
timeout:55000,
dataType:"xml",
error:function(XMLHttpRequest, textStatus, errorThrown){
alert("error="+XMLHttpRequest+" error2="+textStatus+" error3="+errorThrown);
},
success:function(response){
alert('sucess');
}
});
and the content of the proxy.php is following.
<?php
header('Content-type: application/xml');
echo file_get_contents('http://server.name/somefile.php');
?>
It connects to another server where somefile.php
generates some xml content and prints it.
It works perfectly in Chrome, but in Mozilla it shows me my error alert.
What is wrong here?
update 1
I am using firebug and it says that everything is just OK. Even it shows the response from the server. And here is what my error alert prints:
error=[object XMLHttpRequest] error2=parsererror error3=parsererror
update 2
When I open http://server.name/somefile.php from the Mozilla it shows me this message:
XML Parsing Error: not well-formed
Location: http://authoringtool/views/jquery/js/private/visual_constructor/proxy.php
Line Number 8, Column 94: <xs:annotation><xs:documentation xml:lang="en">Network Type</xs:documentation></xs:annotatin>
But again when I open it from Chrome it doesn't show me the error but prints the content of the somefile.php
I think you're doing a cross-server request (more importantly, a cross-domain request ), and as such, you need to do extra security stuff.
https://developer.mozilla.org/En/HTTP_access_control
https://developer.mozilla.org/En/Server-Side_Access_Control
http://arunranga.com/examples/access-control/
Firebug
Also, with Firebug, debugging is better as objects, then you can inspect the returned objects.
console.log({ "error": XMLHttpRequest, "error2": textStatus, "error3": errorThrown });
Try setting the content type from the query itself:
$.ajax({
type:"GET",
url:"views/jquery/js/private/visual_constructor/proxy.php",
data:null,
timeout:55000,
contentType: "application/xml;charset=UTF-8",
dataType:"xml",
error:function(XMLHttpRequest, textStatus, errorThrown){
alert("error="+XMLHttpRequest+" error2="+textStatus+" error3="+errorThrown);
},
success:function(response){
alert('sucess');
}
});
You open with:
<xs:annotation>
And close with:
</xs:annotatin>
Fix the spelling error and the problem should go away.