Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/375.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/77.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 打印服务器响应_Javascript_Jquery_Perl_Httpresponse - Fatal编程技术网

Javascript 打印服务器响应

Javascript 打印服务器响应,javascript,jquery,perl,httpresponse,Javascript,Jquery,Perl,Httpresponse,我正在使用一个用Perl进行验证的表单。我可以在chrome开发工具的网络下的XHR中看到响应。我想打印“响应”错误 看起来是这样的: {type: "error", message: "Unable to located your account by this email address: tim@example.com"} message:"Unable to located your account by this email address: tim@example.com" type

我正在使用一个用Perl进行验证的表单。我可以在chrome开发工具的网络下的XHR中看到响应。我想打印“响应”错误

看起来是这样的:

{type: "error", message: "Unable to located your account by this email address: tim@example.com"}
message:"Unable to located your account by this email address: tim@example.com"
type: "error"
/vsap/mail_id.html?email=tim%40example.com
标题请求如下所示:

{type: "error", message: "Unable to located your account by this email address: tim@example.com"}
message:"Unable to located your account by this email address: tim@example.com"
type: "error"
/vsap/mail_id.html?email=tim%40example.com

我是否可以使用jQuery访问错误消息?

我建议您阅读。我假设这就是您向服务器发出请求的方式。您可以提供一个记录在案的失败回调。因此,您应该在调用之后添加另一个到.failfunctionjqXHR、status、error{}的函数,并在该函数中处理错误。此外,还可以使用status以不同的方式处理不同的错误类型。失败的文档是:

请求失败时要调用的函数。函数接收 三个参数:jQuery1.4.x中的jqXHR、XMLHttpRequest对象和 描述发生的错误类型的字符串,以及可选的 异常对象(如果发生)。第二个参数的可能值 除null之外的参数还有超时、错误、中止和 解析器错误。当HTTP错误发生时,ErrorSprown接收 HTTP状态的文本部分,例如未找到或内部 服务器错误。从jQuery1.5开始,错误设置可以接受数组 函数的定义。每个函数将依次调用。注意:此处理程序 对于跨域脚本和JSONP请求不调用。这是一个 Ajax事件


能否将用于发出ajax请求的JavaScript代码发布到perl?