一旦用户点击删除按钮我的 jQuery 脚本要求服务器删除所选项目。
现在我想要我的php发送成功或错误响应的脚本。
是否有可能触发错误回调万一该项目无法删除?
Thanks
我的 jQuery 代码:
$.ajax({
type: "post",
url: "myAjax.php" ,
dataType: "text",
data: {
some:data
},
error: function(request,error)
{
// tell the user why he couldn't delete the item
// timeout , item not found ...
},
success: function ( response )
{
// tell the user that the item was deleted
// hide the item
}
);
header("HTTP/1.0 404 Not Found");
header('HTTP', true, 500); // 500 internal server error
// etc etc..
查看header() http://php.net/header以获得更多选择。所有 HTTP 错误代码都可供使用。
相关问题:如何使用 ASP.NET MVC 在 jQuery AJAX 调用中触发“错误”回调? https://stackoverflow.com/questions/407651/how-do-you-trigger-the-error-callback-in-a-jquery-ajax-call-using-asp-net-mvc
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)