jQuery $.get or $.post to catch page load error (eg. 404)

后端 未结 5 1314
予麋鹿
予麋鹿 2020-12-09 04:06

How do you catch Server Error or 404 page not found, when you use $.get or $.post ?

For example:

$.post(\"/myhandler\", { value: 1 }, function(data)          


        
5条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-09 05:03

    Use $.ajax instead and use the error callback.

    http://api.jquery.com/jQuery.ajax/

提交回复
热议问题