Best way to check if AJAX request was successful in jQuery

前端 未结 3 1399
挽巷
挽巷 2021-01-01 21:21

I\'ve been checking to make sure my AJAX requests are successful by doing something like this:

$.post(\"page.php\", {data: stuff}, function(data, status) {
          


        
3条回答
  •  灰色年华
    2021-01-01 21:46

    I prefer to use the ajax call, as it has an explicit success handler

    $.ajax({
    url: "page.php",
    data: stuff,
    success: function(response){
    console.log("success");
    }
    });
    

    I'd also recommend using firebug or webkit similar, then you can track the requests and check the parameters!

提交回复
热议问题