开发者

jEditable, check reply of POST request before deciding what to do

how do i check what the page returns before deciding what 开发者_如何学JAVAto do? for example, if the page returns 404, or timeout, or my own message, i would like to be able to show the users an error message, and revert the value to the original value, instead of printing what the page returns on the value that was edited.

thx in advance.


In the callback option you can catch errors and then alert the user of that error.

On way is via JQuery AJAX error(jqXHR, textStatus, errorThrown).

Possibly another way is that if the error is in the PHP (or equivalent), you can send back JSON data saying something like {error: 0} and then in the callback look something like:

callback: function(data) {
      if(data.error == 0){
           alert("an error occurred!");
      }
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜