有誰知道如何解決這個錯誤?我正在使用jquery 1.6.2XMLHttpRequest無法加載http://www.reddit.com/.xml
XMLHttpRequest無法加載http://www.reddit.com/.xml。來源null爲 Access-Control-Allow-Origin不允許。
$(document).ready(function() {
$.ajax({
type: "GET",
url: "http://www.reddit.com/.xml",
dataType: "xml",
crossDomain: true,
success: xmlParser
});
// ...
});
簡而言之,'crossDomain'不能用xml開箱即用,但它_does_可以與JSONP一起工作。使它與XML協同工作需要一些額外的工作。 –
[需要幫助使用JavaScript獲取跨域XML]的可能重複(http://stackoverflow.com/questions/1550839/need-help-with-getting-cross-domain-xml-with-javascript) – Quentin
嗨,我同意雷,請參閱以下網頁以獲取更詳細的信息:http://www.nczonline.net/blog/2010/05/25/cross-domain-ajax-with-cross-origin-resource-sharing/關注 – Neil