jQuery autocomplete - xml cross site request
The XML feed for my autoc开发者_Go百科omplete is on another server. Is there a client side (javascript) method of getting this XML document?
I know I can create a proxy with php, jsp, etc.. but I need to do it all client side. This is how I call the file now that only works if it is on the same domain:
function callAjax(url) {
$.ajax({
url : url,
dataType : "xml",
success : function(xmlResponse) {
totalrec = $("TOTALREC", xmlResponse).text();
$.merge(data1, $("ROW", xmlResponse).map(returnResults).get());
}// end of success
});
You could do it using JSONP
dataType: 'jsonp'
Here you have living demo:
http://jqueryui.com/demos/autocomplete/#remote-jsonp
This doesn't do it with xml, but json. But shouldn't be hard to change it.
hope this helps. Cheers
YQL might be able to do what you want. It allows you to do cross-domain requests.
Have a look at this: Cross-domain requests with jQuery
H.T.H
精彩评论