Jquery xml parser not working in Chrome?
I have this jquery code:
$.ajax({
type: "GET",
url: "http://api.ipinfodb.com/v2/ip_query.php?key=3b80b5588c22d2a03c0e6979d1e85e397e043646c4a65ffe47ff01d47bce51e",
dataType: "xml",
success开发者_StackOverflow中文版: function(xml) {
alert('Success?');
$(xml).find('Response').each(function(){
var status = $(this).find('Status').text()
alert(status);
});
}
});
It work in IE but not in Chrome, any clue?
Thanks in advance!
I think you are aware of the same origin policy restriction which prevents you from sending AJAX requests cross domain. JSONP is one possible workaround but from what I can see the url you are trying to fetch doesn't return JSONP formatted data. You might want to check the documentation of your provider to see if it supports JSONP. Another possible workaround is to use a server side script on your domain which will act as a bridge between your domain and the distant domain and then you would send the AJAX request to this script.
精彩评论