最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Why is this failing in IE? - Stack Overflow

programmeradmin0浏览0评论

My website fails in IE. I only have access to Macs so it's hard to test and parallels is meh. I have been able to check once or twice so I know it fails when it searches youtube.

Close the popup > Hit 2010 > Hit 10/20 > Hit My Soul > Error

/

Could anyone provide some insight? Here's the code where it fails:

Thanks!

My website fails in IE. I only have access to Macs so it's hard to test and parallels is meh. I have been able to check once or twice so I know it fails when it searches youtube.

Close the popup > Hit 2010 > Hit 10/20 > Hit My Soul > Error

http://www.phishvid./

Could anyone provide some insight? Here's the code where it fails:

Thanks!

Share Improve this question edited Jan 27, 2011 at 16:38 switz asked Jan 27, 2011 at 6:22 switzswitz 25.3k27 gold badges79 silver badges105 bronze badges 9
  • 1 which version of IE? things involving JS often fail on IE <=7 or <=6 cause of different versions of MS's interpretation of the standard – tobyodavies Commented Jan 27, 2011 at 6:29
  • I believe all of them. I'm really unable to test it well. Do you think you could check really quick? Thanks. – switz Commented Jan 27, 2011 at 6:30
  • 2 This is a cross-site scripting issue, IE is likely blocking the ajax/json request. Check out this: stackoverflow./questions/3038862/… – Craig Commented Jan 27, 2011 at 6:31
  • I've honestly tried jsonp 50 times and spent hours and could never get it working with youtube (at least to retrieve the youtube link/id). Do you think you could show me how it works? – switz Commented Jan 27, 2011 at 6:33
  • 1 I don't often give out upvotes for stupid reasons but +1 for Phish – aaronasterling Commented Jan 27, 2011 at 8:14
 |  Show 4 more ments

2 Answers 2

Reset to default 4

You are trying to make an AJAX request to a different domain, which is being restricted by the Same Origin Policy.

To over e this use JSONP, to make your request use JSONP callback=? to the url that your requesting, this will help you overe the cross-domain barrier.

You updated url should look like

 $.getJSON("http://gdata.youtube./feeds/api/videos?callback=?&max-results=5&alt=json&q=phish " + song + " " + month2 + " " + day + " " + year, function (data) {
   //your callback code
 }

Example

My IE reports "Access is denied" in jquery-1.4.4.min.js on line 138, char 355 which on your site looks like this:

if(w){b.username?w.open(h,b.url,b.async,b.username,b.password):w.open(h,b.url,b.async);try{if(b.data!=null&&!l||a&&a.contentType)w.setRequestHeader("Content-Type",
b.contentType);if(b.ifModified){c.lastModified[b.url]&&w.setRequestHeader("If-Modified-Since",c.lastModified[b.url]);c.etag[b.url]&&w.setRequestHeader("If-None-Match",c.etag[b.url])}o||w.setRequestHeader("X-Requested-With","XMLHttpRequest");w.setRequestHeader("Accept",b.dataType&&b.accepts[b.dataType]?b.accepts[b.dataType]+", */*; q=0.01":b.accepts._default)}catch(I){}if(b.beforeSend&&b.beforeSend.call(b.context,w,b)===false){b.global&&c.active--===1&&c.event.trigger("ajaxStop");w.abort();return false}b.global&&
c.triggerGlobal(b,"ajaxSend",[w,b]);var L=w.onreadystatechange=function(m){if(!w||w.readyState===0||m==="abort"){J||c.handleComplete(b,w,e,f);J=true;if(w)w.onreadystatechange=c.noop}else if(!J&&w&&(w.readyState===4||m==="timeout")){J=true;w.onreadystatechange=c.noop;e=m==="timeout"?"timeout":!c.httpSuccess(w)?"error":b.ifModified&&c.httpNotModified(w,b.url)?"notmodified":"success";var p;if(e==="success")try{f=c.httpData(w,b.dataType,b)}catch(q){e="parsererror";p=q}if(e==="success"||e==="notmodified")d||
c.handleSuccess(b,w,e,f);else c.handleError(b,w,e,p);d||c.handleComplete(b,w,e,f);m==="timeout"&&w.abort();if(b.async)w=null}};try{var g=w.abort;w.abort=function(){w&&Function.prototype.call.call(g,w);L("abort")}}catch(i){}b.async&&b.timeout>0&&setTimeout(function(){w&&!J&&L("timeout")},b.timeout);try{w.send(l||b.data==null?null:b.data)}catch(n){c.handleError(b,w,null,n);c.handleComplete(b,w,e,f)}b.async||L();return w}

the actual character number 355 is the first b, so I'm guessing you might have e across a bug in jQuery 1.4.4? you could try to either use a previous version (unless you are using some 1.4.4 specific features) or replace the .min.js file with the full jquery file, insert a debugger-statement into the jquery-file at this location (before it throws the exception) and try to debug to figure out what is wrong. You can for instance use Microsoft Visual Web developer to debug, or if the same issue occurs in IE9 it has a built in .js - debugger as well

EDIT: after seeing the full jQuery code you posted it is clear that the problem is that jQuery in this case is trying a standard ajax call, not JSONP. (standard ajax only allowed back to the server which served the javascript)

发布评论

评论列表(0)

  1. 暂无评论