如何使用php发送服务器错误响应?
发布时间:2020-12-13 16:27:43 所属栏目:PHP教程 来源:网络整理
导读:一旦用户点击删除按钮,我的jQuery脚本会要求服务器删除所选项. 现在我要我的php脚本发送成功或错误响应. 是否可以触发错误回调,以防该项目无法删除? 谢谢 我的jQuery代码: $.ajax({ type: "post",url: "myAjax.php",dataType: "text",data: { some:data },
一旦用户点击删除按钮,我的jQuery脚本会要求服务器删除所选项.
现在我要我的php脚本发送成功或错误响应. 是否可以触发错误回调,以防该项目无法删除? 谢谢 我的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错误代码都可以使用. 相关问题:How do you trigger the “error” callback in a jQuery AJAX call using ASP.NET MVC? (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |