2011-03-11 34 views
7

當我升級到jQuery 1.5.1(或1.5)時,我的站點中的所有調用都會在錯誤選項函數中產生一個「parserror」。還有一個腳本錯誤jQuery 1.5.1打破所有ajax()調用

Uncaught SyntaxError: Unexpected token : jquery-1.5.1.min.js:16 

該網站一直運行沒有使用1.4.4錯誤。這是來自ajax()調用之一的代碼。

$.ajax({ 
    url: '/CustomerGroup/Get', 
    type: 'POST', 
    contentType: 'application/json; charset=utf-8', 
    dataType: 'json', 
    success: function (grp) { 
    if (grp != null) { 
     clear(); 
     group = grp; 
     load(grp); 
    } else{ 
     showError(
        'Customer Group', 
        'Whoops, error getting customer group information. Please contact [email protected] and include your username and date/time of the error.' 
        ); 
      } 
    }, 
    error: function (x,s,e) { 
    showError(
     'Customer Group', 
     'Whoops, error getting customer group information. Please contact [email protected] and include your username and date/time of the error.' 
    ); 
    } 
}); 

經過很多研究,我找不出爲什麼發生錯誤。任何見解都會被讚賞

編輯: 使用jQuery的完整版我得到如下:

Uncaught SyntaxError: Unexpected token : 
d.d.extend.globalEvaljquery-1.5.1.js:16 
d.ajaxSetup.converters.text scriptjquery-1.5.1.js:16 
bJjquery-1.5.1.js:16 
wjquery-1.5.1.js:16 
d.support.ajax.d.ajaxTransport.send.cjquery-1.5.1.js:16 

和YES我使用jquery.validate。

+0

嘗試使用jQuery(jQuery的1.5.1.js代替jQuery的1.5.1.min.js)和帖子的全部不精縮版錯誤的行號。 – rsp 2011-03-11 18:25:33

+0

隨機問題 - 你也使用jquery.validate與你的代碼?在這種情況下,我收到了確切的錯誤。它適用於1.4.4。 – JasCav 2011-03-11 18:27:29

+0

除非你發佈了在使用jQuery的開發(而非縮小版)時得到的錯誤消息,否則我們甚至無法知道jQuery的哪個部分會導致問題,因爲在jQuery的縮小版本中基本上所有東西都在行16. – rsp 2011-03-11 18:38:17

回答

8

這是jQuery validation plugin中的一個錯誤。兩天前我遇到了同樣的問題。正如它在jQuery驗證插件網站上所說的,版本1.7是而不是與jQuery 1.5.x兼容。

您需要安裝Jörn的github頁面上的newer version of validate

+0

謝謝。在jQuery論壇中得到了相同的答案,並得到了修復。 – ChrisP 2011-03-11 18:50:48