Wrap jQuery's $.ajax() method to define global error handling

前端 未结 4 1808
攒了一身酷
攒了一身酷 2021-01-03 20:54

Branching off of questions like this one, I\'m looking to wrap jQuery\'s $.ajax() method such that I can provide error handling in one location, which would then be used aut

4条回答
  •  青春惊慌失措
    2021-01-03 21:24

    I think it's a bad idea. I think wrapping $.ajax is fine, but you're talking about re-defining it. Anyone who doesn't realize this will get unexpected results.

    As others have mentioned, binding a handler to $.ajaxError is the way to go.

提交回复
热议问题