2012-02-01 47 views
0

的JSON請求加入我的頁面有這些JavaScript代碼:回調jQuery中

<script type="text/javascript"> 
$(function() { 
    $.getJSON("http://example.com/index.php/grid/fetch-grid", function(jsonData) { 
    if (jsonData.status === true) { 
     $("#parserFilterGridContainer").html(jsonData.content); 
    } else { 
     // Alert that loading failed 
     alert(jsonData.content); 
    } 
    }); 
}); 
</script> 

,當我檢查的螢火從服務器請求的URL是

"http://example.com/index.php/grid/fetch-grid?callback=.... (some numbers)" 

,而不是 「http://example.com/index.php/$$$call$$$/grid/fetch-grid」

我的jQuery的版本是V1.5.1。 是因爲我的jQuery版本嗎? 我該如何解決它?

+0

的jQuery 1.5.2沒有表現出與上面的確切的代碼這種行爲。 http://jsfiddle.net/LRsRy/你可能在代碼的其他地方有一些全局的Ajax設置嗎?請參閱http://api.jquery.com/jQuery.ajaxSetup/ – 2012-02-01 06:03:29

回答

0

好了,現在解決了。我將我的jquery從1.5.1升級到1.7,問題解決了。似乎v1.5.1將getJSON視爲JSONP而不是JSON。