jquery ajax done function not firing

前端 未结 5 1337
我寻月下人不归
我寻月下人不归 2020-12-11 14:42

I have a VERY simple jQuery Ajax call (below). The Ajax call executes and I can see in the Firebug Net panel that the server returned 200 OK and returned a string \"OK\" as

5条回答
  •  一生所求
    2020-12-11 15:23

    success and error callbacks can be used in that way. For done and fail, you need to do :

    $.ajax({
        type: "POST", 
        url: postUrl,
        data: dataToPost,
    }).done(function() {
        alert("Success.");
    }).fail(function() {
        alert("Sorry. Server unavailable. ");
    });
    

    Or :

    $.ajax({
        type: "POST", 
        url: postUrl,
        data: dataToPost,
        success: function() {
                //code here
        }
    });
    

提交回复
热议问题