Jquery.get cannot retrieve XML from RESTful Service
I'm trying to get an XML document from a REST service using the Jquery get method, but it doesn't seem to be able to download. After only about 11 seconds, the connection dies and I receive a blank document. I've tested out the URL by accessing it through the browser, and it works (even though it takes 4 minutes to load).
$(document).ready(function()
{
$.get(
siteUrl,
function(data) { parseXml(data); }
);
});
I've considered using the ajax method, because you can set the timeout, but the same domain policy applies, restricting m开发者_运维知识库e from using it. Any ideas?
From documentation for jQuery.get()
This is a shorthand Ajax function, which is equivalent to:
$.ajax({
url: url,
data: data,
success: success,
dataType: dataType
});
So I'm not sure what you mean by "but the same domain policy applies, restricting me from using it." But if $.get
works, so will $.ajax
Okay, .get and .ajax will not work since they are not under the same domain, thus violating the Same Origin Policy.
To get around this, we can use the .getJson method (more information found on IBM's site)
However, in my situation, the desired output is not Json, thus we can use something like YQL from Yahoo to accomplish... or just use a proxy server on your domain.
精彩评论