Confused on jquery .ajax .done() function

前端 未结 3 548
无人及你
无人及你 2021-02-08 03:29

I\'m a bit confused on how to use the ajax .done() function. I\'m working on validating a form to check if a user exists in database and though ajax would be the best approach (

3条回答
  •  灰色年华
    2021-02-08 04:17

    Success: It will return the XHR success status, eg: 200
    Done: Once XHR get success then it will complete the and return with a return data

    Try below code

     $.ajax({
    type: "POST",
    url: Url,
    data: dataParameter,
    async: true,
    success: function(results, textStatus) {
        debugger;
        console.log("success : " + results);
    },
    error: function(xhr, status, error)
    {
        console.log("error : " + xhr.responseText);                   
    }
    }).done(function(results) {
        debugger;          
        console.log("done : " + results);           
    });
    

提交回复
热议问题