Re: [問題] IE 9 ajax calling fail

看板Ajax作者 (鞭策自己社清流夜靈)時間14年前 (2011/05/03 04:15), 編輯推噓0(002)
留言2則, 2人參與, 最新討論串2/2 (看更多)
自問自答一下,我後來發現問題是出在IE8/IE9對於 console.log() 這個function有相容性的問題, 在還沒有打開developer tool的時候,如果執行到這行就會直接死給你看, 然而開了developer tool後這行指令就會順利被執行, 甚至關掉tool後還是會正常跑... 我之前在success裡面其實是用console.log去track而不是用alert, 所以才會有沒開developer tool不會正常觸發success的症頭... 習慣用console.log來logging的人請注意囉 :P 另外補一個針對這問題的討論串: http://goo.gl/9nJkx ※ 引述《nightspirit (鞭策自己社清流夜靈)》之銘言: : 我寫了一個AJAX call去抓後端給的JSON然後產生一個動態圖庫 : 程式碼在 Chrome/Firefox跑都沒問題 : var imgUrl = []; : $.ajax({ : type: "POST", : contentType: "application/json", : url: ajaxurl, : dataType: "json", : success: function (data) { : //alert("success"); : imgUrl = eval(data.d); : if (imgUrl.length) { : buildGallery(pageIndex); : } : } : }); : 然而IE9一直給我出問題,我試著用alert debug, : 但發現Success callback根本不會被呼叫, : 當我試著用IE9內建的developer tool debug的時候, : 居然json就可以成功取到並呼叫success function, : 實在是超級詭異的症頭,有人也碰過同樣的情況嗎? -- ┌─┐ ┌─── 斷 面 ──┐ │ └Continu └┐ │ Dis ┌─┤┌┤ ┌Mind┐ └ 因為想法是那麼不連續 ┐│ └┘Ous┤ └ 解 構 ┌──┘ └┘ 思 考 ──────┐ § http://blog.nightspirit.tw § 所以書寫‧解構 -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 64.166.83.198

05/03 19:23, , 1F
console.log =.=
05/03 19:23, 1F

05/19 10:28, , 2F
console.log 會出錯的原因應該是ie 找不到這個object
05/19 10:28, 2F
謝謝指正 :) ※ 編輯: nightspirit 來自: 64.166.83.194 (05/27 05:07)
文章代碼(AID): #1Dln3u-S (Ajax)
討論串 (同標題文章)
文章代碼(AID): #1Dln3u-S (Ajax)