[英]java script to get xml from url
I am writing a js to get a xml from a url but i am not getting any response.Anything I am doing wrong? 我正在写一个js从URL获取xml,但是没有任何响应。我做错了什么吗?
$(document).ready(function () {
$.ajax({
type: "GET",
url: "http://www.w3schools.com/xml/simple.xml",
dataType: "xml",
success: function(response)
{
alert(response);
}
});
});
http://jsfiddle.net/4bh0qpb1/1/ http://jsfiddle.net/4bh0qpb1/1/
您忘记用双引号将url参数结尾
First script syntax error (") that you have fixed, although you can't access following url http://www.w3schools.com/xml/simple.xml
using ajax due to CORS (Cross-origin resource sharing) Policy. 您已解决的第一个脚本语法错误(“),尽管由于CORS(跨域资源共享)策略而无法使用Ajax访问以下URL
http://www.w3schools.com/xml/simple.xml
。
Reason Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at http://www.w3schools.com/xml/simple.xml . 原因跨源请求被阻止:“同源起源”策略不允许读取http://www.w3schools.com/xml/simple.xml上的远程资源。 This can be fixed by moving the resource to the same domain or enabling CORS.
可以通过将资源移到同一域或启用CORS来解决此问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.