jQuery 1.5.1 中断所有 ajax() 调用
当我升级到 jQuery 1.5.1(或 1.5)时,我网站中的所有 ajax()
调用都会在错误选项函数中产生“parserror”。还有一个脚本错误
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
是的,我正在使用 jquery.validate。
When I upgrade to jQuery 1.5.1 (or 1.5) all of the ajax()
calls in my site produce a "parserror" in the error option function. There is also a script error
Uncaught SyntaxError: Unexpected token : jquery-1.5.1.min.js:16
The site has been running w/o errors using 1.4.4. Here is code from one of the ajax() calls.
$.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.'
);
}
});
After much research I can not figure out why the error is occurring. Any insights appreciated.
EDITED:
With the full version of jQuery I get the following:
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
and YES I am using jquery.validate.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这是 jQuery 验证插件 中的一个错误。两天前我遇到了完全相同的问题。正如 jQuery 验证插件网站上所说,1.7 版不与 jQuery 1.5.x 兼容。
您需要从 Jörn 的 github 页面安装较新版本的 validate。
This is a bug in the jQuery validation plugin. I hit the exact same problem two days ago. As it says on the jQuery validation plugin site, version 1.7 is not compatible with jQuery 1.5.x.
You need to install the newer version of validate from Jörn's github page.
请参阅 http://bugs.jquery.com/ticket/8302
并尝试
dataType:代码中的 'text json'
see http://bugs.jquery.com/ticket/8302
and try
dataType: 'text json'
in your code