error handling with .post()

前端 未结 3 859
囚心锁ツ
囚心锁ツ 2021-01-31 13:50

I have to modify a project written by someone else. Because the code is a mess I can\'t really change this $.post() (or replace it by $.ajax()). What I need to do, is to know if

3条回答
  •  故里飘歌
    2021-01-31 14:28

    You can use $.ajax() ($.post is a shortcut that ends up calling it anyway), and define the error callback.

    Or, if you really do not want to do that, call

    $.ajaxError(function(){
       //error handler
    })
    

    before that $.post

提交回复
热议问题