New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

跨域ajax请求时候报错 #151

Closed
boyzhou99 opened this Issue Aug 5, 2014 · 1 comment

Comments

Projects
None yet
2 participants
@boyzhou99
Copy link

boyzhou99 commented Aug 5, 2014

$('#register_form').validator({
rules:{
emailremote: function(element){
return $.ajax({
url: 'http://code.huicat.com/codecheckadd.aspx',
jsonp: "jsonp_callback",
dataType: 'jsonp',
success: function(success){
console.log('success!');
//console.log('success:'+d);
//console.log('测试错误邮箱正确验证');
},
error:function(error){
console.log('error!');
//console.log(error)
//console.log('测试错误邮箱实时验证');
}
})
}
},
fields: {
'user[email]': {
rule: 'emailremote;'..........

当自定义ajax 时候 通过jsonp 跨域请求时候会报错 chrome 下Uncaught TypeError: Cannot read property 'charAt' of undefined
firefox 下报错为 TypeError: c is undefined

@boyzhou99

This comment has been minimized.

Copy link
Author

boyzhou99 commented Aug 5, 2014

发现nice 只做了json 判断 对于jsonp 没有判断
nice.js 加入判断就好了
// detect if it is json format
if (this.dataType === 'json') {
data = d;
}else if (this.dataType === 'jsonp'){
data = d;
} else if (data.charAt(0) === '{') {
data = $.parseJSON(data) || {};
}

@niceue niceue closed this in 97cec70 Aug 5, 2014

niceue added a commit that referenced this issue Aug 5, 2014

@niceue niceue added the bug label Aug 7, 2014

@niceue niceue added this to the 0.8.0 milestone Aug 7, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment