Actually, I dont know if it's a crossdomain ajax problem. Here is my problem: I have a website running under ssl protocol, for example, the website url address is: https://172.11.8.1:10443/index.php, now I would like to get some xml data from another http process in the same server, say: http://172.11.8.1:8080/test.xml.
My assumption is, I could just add a js file in the HTML page of https://172.11.8.1:10443/index.php, the core ajax call is like the following:
$.ajax({
type: "GET",
url: "http://172.11.8.1:8080/test.xml",
dataType:"xml",
success: xmlParser,
error: errHandler
});
function xmlParser (xml, textStatus)
{
//
}
function errHandler(xhr, statusText, error)
{
if (xhr.status == "0" && statusText == "error")
{
alert("network down");
}
else if (xhr.status == "200" && statusText == "parseerror")
{
alert("error to get xml info");
}
else
{
alert("error to get xml info");
}
}
as I follow the js file, it's always go into error handle function directly. And the error information is like:
errorType Error: a is null message=a is null
statusText parsererror
I believe the XML file format is valid,开发者_如何学C because I tried the same ajax call under the same http domain, it works.
Any suggestions?
You can get around the cross-domain issue in this case ... just create a page in (for example) php that gets the feed....
getXml.php
<?php die(file_get_contents('http://172.11.8.1:8080/test.xml')); ?>
js
$.ajax({
type: "GET",
url: 'getXml.php',
dataType:"xml",
success: xmlParser,
error: errHandler
});
精彩评论