通过Ajax调用来调用远程XML [英] Call a remote XML by Ajax call
问题描述
我在远程服务器上有一个xml.现在我想用ajax来称呼它. IE正在提供所需的结果.但是Firefox和chrome不能.请给我解决方案.我用谷歌搜索,但没有找到解决方案.
I have a xml in a remote server. Now i want to call it with ajax. IE is giving the required result. But Firefox and chrome cant. Please give me the solution. I google it but did not find the solution.
$.support.cors = true;
$.ajax({
type: "GET",
url: "http://www.w3schools.com/xml/note.xml",
dataType: "xml",
success: function(node)
{
alert(node);
},
error: function()
{
alert("Network Error");
}
});
推荐答案
是的,您肯定会遇到ajax跨域问题.现在可以使用两种方法.
Yes You are definitely stuck with ajax cross-domain issue.there is two approaches that you can use now.
- First is using a proxy.example YQL.
- Using cross-origin resource sharing
这是在这里分享的一个小话题,我不会在您的代码中实现它.但是,如果您检查了这些内容,我相信您可以解决此问题.
AS this is a little wast topic to share here.I won't go to implement it here on your code.But If you check these things I am sure you can sort this issue out.
编辑一个简单的Google搜索最终在此处. 在其他人更清楚地解释了该解决方案的地方.您可以使用它.
Edit a simple google search ended up here . Where some one else had explained the solution more clearly.You can take use of it.
这篇关于通过Ajax调用来调用远程XML的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!