为了账号安全,请及时绑定邮箱和手机立即绑定

为什么ajax post json后,返回200,但是ajax回调函数却进入error?

为什么ajax post json后,返回200,但是ajax回调函数却进入error?

哔哔one 2018-11-15 18:18:18
这是ajax代码:$.ajax({      url: '/api/v1/register',      data: JSON.stringify({username: $username, email: $email, password: $password}),      contentType: 'application/json',      type: 'POST',      dataType: 'json',      success: function (msg) {        console.log(msg)        console.log('hello!')      },      error: function (error_msg) {        console.log(error_msg)        console.log('wrong!')      }    })
查看完整描述

1 回答

?
大话西游666

TA贡献1817条经验 获得超14个赞

因為返回的內容不是json格式,識別不出來,所以去了error。你可以console.log(error_msg)


查看完整回答
反对 回复 2018-12-31
  • 1 回答
  • 0 关注
  • 554 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号