javascript - Cant make a crossdomain Ajax call - Stack Overflow

$(document).ready(function(){$.ajax({url: "",type: "GET",success: function(msg){con

$(document).ready(function(){ $.ajax({ url: "", type: "GET", success: function(msg){ console.log(msg); } }); });

i get this error "XMLHttpRequest cannot load "

How can i make crossdomain ajax calls to get the xml from the api?

$(document).ready(function(){ $.ajax({ url: "http://gdata.youtube./feeds/api/users/zdf/playlists?v=2", type: "GET", success: function(msg){ console.log(msg); } }); });

i get this error "XMLHttpRequest cannot load http://gdata.youtube./feeds/api/users/zdf/playlists?v=2"

How can i make crossdomain ajax calls to get the xml from the api?

Share Improve this question asked Sep 9, 2010 at 8:10 antpawantpaw 16k11 gold badges63 silver badges94 bronze badges
Add a ment  | 

3 Answers 3

Reset to default 6

You cannot make a crossdomain call to to get XML. Your only choice to receive data crossdomain is JSON-P.

The same origin policy restricts direct access to a foreign domain (ajax/iframes), json-p uses dynamic script tag insertion to workaround this issue.

Have a look at http://api.jquery./jQuery.getJSON/. JSON-P is also covered there.

edit

http://code.google./intl/de-DE/apis/youtube/2.0/developers_guide_json.html

Made for you!

There is an ongoing standardization process to work out a scheme to allow cross-domain ajax requests JSON-P is just a temporary workaround since it uses the script tag to make HTTP requests, which is inferior to the XMLHttpRequest object.

The proposed solution is based on letting the resource origin specify which domains that are allowed to make cross-domain requests, the domain "*" means that any other web page can host an application that makes requests to that specific resource.

You can read more in the w3c Working draft

This is supported in modern web-browsers.

try $.load() . see http://api.jquery./load/

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1742372295a4431491.html

相关推荐

  • javascript - Cant make a crossdomain Ajax call - Stack Overflow

    $(document).ready(function(){$.ajax({url: "",type: "GET",success: function(msg){con

    1天前
    30

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信