admin管理员组文章数量:1414873
I am writing a simple bookmarklet that runs on youtube page and fetch some data from the youtube api about the current playing video.
The bookmarket runs on Chrome and Firefox,but on IE(currently tested only on IE9) I am getting error from the next code :
jQuery.support.cors = true;
$.getJSON('/' + vid + '?v=2&alt=json',YoutubeBookmarklet.handle_gdata_obj)
.error(function(xhr, ajaxOptions, thrownError) {
console.log(thrownError);
});
The first error I got was "No Transport",by the help of stackoverflow I saw that I need to add jQuery.support.cors = true in order to fix it,after adding it I am getting another error : "Access is denied."
I tried to use the IE XDomainRequest,but I get the same error.
What to do?
I am writing a simple bookmarklet that runs on youtube page and fetch some data from the youtube api about the current playing video.
The bookmarket runs on Chrome and Firefox,but on IE(currently tested only on IE9) I am getting error from the next code :
jQuery.support.cors = true;
$.getJSON('https://gdata.youtube./feeds/api/videos/' + vid + '?v=2&alt=json',YoutubeBookmarklet.handle_gdata_obj)
.error(function(xhr, ajaxOptions, thrownError) {
console.log(thrownError);
});
The first error I got was "No Transport",by the help of stackoverflow I saw that I need to add jQuery.support.cors = true in order to fix it,after adding it I am getting another error : "Access is denied."
I tried to use the IE XDomainRequest,but I get the same error.
What to do?
- Javascript does not allow cross domain $.get's like that, read en.wikipedia/wiki/Same_origin_policy – Phil Commented Aug 5, 2011 at 15:46
-
Hi,Phil,I don
t think you are right,If this is were true then my code won
t run on chrome or firefox. – Yosi Commented Aug 5, 2011 at 15:54
2 Answers
Reset to default 3I fixed it using JSONP in order to do so i added "&callback=?" to the end of the url.
Looks like a cross domain call, take a look at this hope it will help you.
http://james.padolsey./javascript/cross-domain-requests-with-jquery/
本文标签: javascriptjQuerygetJSON Acess DeniedStack Overflow
版权声明:本文标题:javascript - jQuery.getJSON Acess Denied - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745223690a2648509.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论