2013-04-05 70 views
0

我的代碼在IE10中(或以前)在我的工作計算機上不起作用,但似乎在我的家用計算機上正常工作。我不認爲它甚至提出請求,因爲我設置了斷點並在網絡選項卡中看不到任何內容。我已經閱讀了很多有關在IE中使用$ .ajax緩存問題的文章,並嘗試過緩存解析器和$ .get等,但我不認爲這是問題所在。你可以在timmygcentral.com上看到這個(腳本在index.html中的loadReccomendations函數中)。它必須是一些安全問題(因爲它只發生在我的工作網絡在IE中,它可以在我的工作網絡在Chrome/FF中正常工作,並在所有瀏覽器中在我的家庭網絡上正常工作)。jQuery.ajax在任何IE中都不工作

var tgc_recommendations_uri = "https://spreadsheets.google.com/feeds/list/0AsRjUFPfaIWvdGxPT3U0ZGRNUnFGakwwQnpKQi1Hbnc/od6/public/values?alt=json"; 
$.ajax({ 
    cache: false, 
    type: "GET", 
    contentType: "application/json", 
    url: tgc_recommendations_uri, 
    format: "jsonp", 
    success: function(data){ 
    $('#recCarousel').css('opacity','0') 
    var template = "..."; 
    var html = Mustache.to_html(template, data.feed); 
    } 
}); 
+1

包括async:false由於您使用JSONP,它不應該是一個跨域的問題。 contentType可以保留,因爲它是jsonp,並且如果失敗,您會在控制檯中看到錯誤。另外,'格式:「jsonp」'應該是'dataType:「jsonp」' – 2013-04-05 14:13:22

+0

好!用dataType替換格式工作! – timmyg13 2013-04-05 14:21:52

+0

good catch @KevinB +1 – iGanja 2013-04-05 16:56:45

回答

0

在你的Ajax

像這樣

var tgc_recommendations_uri = "https://spreadsheets.google.com/feeds/list/0AsRjUFPfaIWvdGxPT3U0ZGRNUnFGakwwQnpKQi1Hbnc/od6/public/values?alt=json"; 
$.ajax({ 
    cache: false, 
    type: "GET", 
    contentType: "application/json", 
    url: tgc_recommendations_uri, 
    format: "jsonp", 
    async:false, 
    success: function(data){ 
    $('#recCarousel').css('opacity','0') 
    var template = "..."; 
    var html = Mustache.to_html(template, data.feed); 
} 
}); 
+0

'async:false'如何提供幫助? – jrummell 2013-04-05 13:56:16

+0

當你在某個地方的某個地方刪除「異步」行爲時,可能有些小狗死亡。不要這樣做PLZ – kidwon 2013-04-05 13:58:16

+0

反正沒有工作。這可能是一個跨域問題嗎?控制檯或任何東西都沒有出現。 – timmyg13 2013-04-05 13:59:43