簡體   English   中英

Ajax錯誤:200響應碼

[英]Ajax Error: 200 Response Code

我正在使用jQuery Form插件來處理Ajax提交的表單:

$('.login-form').ajaxForm({
    dataType: 'json',
    success: function(data){
        console.log('Success!');
        console.log(data);
    },
    error: function(data){
        console.log('There was an error:');
        console.log(data);
    }
})

提交后,ajax返回狀態為“ 200”的錯誤。 這是JSON格式的響應:

{
    "success": false, 
    "heading": "The following errors were encountered", 
    "message": "<ul><li>The existing username and/or password you submitted are not valid</li></ul>"
}

我通過jsonlint.com進行了運行,它返回為有效。

在Chrome的“網絡”標簽中,響應以application/json類型application/json

那么,為什么ajax返回“錯誤”而不是“成功”?

jQuery 1.9.1

JSON message鍵的值在其中有一個換行符,由於某種原因導致該錯誤:

{
    "success": false, 
    "heading": "The following errors were encountered", 
    "message": "<ul><li>The existing username and/or password you submitted are not valid</li>
</ul>"
}

我不認為字符串中的換行符很重要,但我想它們確實可以...

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM