Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/357.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中的Java异常类名_Javascript_Java_Jquery_Ajax_Exception - Fatal编程技术网

获取javascript中的Java异常类名

获取javascript中的Java异常类名,javascript,java,jquery,ajax,exception,Javascript,Java,Jquery,Ajax,Exception,我使用以下代码来调用JavaWebAPI m$.ajaxq({ url: contextPath + "/updateElapsedTime", type: "POST", data: params, contentType: "application/json; charset=utf-8", dataType: 'text', async: optionalRunAsync, success: function (response) { console

我使用以下代码来调用JavaWebAPI

m$.ajaxq({
  url: contextPath + "/updateElapsedTime",
  type: "POST",
  data: params,
  contentType: "application/json; charset=utf-8",
  dataType: 'text',
  async: optionalRunAsync,
  success: function (response) {
      console.log("Success")
  },
  error: function (jqXHR, textStatus, errorThrown) {
    console.log("Exception name is ...");
  }
});
现在有一种情况是它抛出自定义异常。
我想知道从JavaAPI抛出了哪个自定义异常(类名),并用javascript打印出来。

检查响应是否不是200。 然后使用

xhr.responseText


这将显示您的自定义错误消息

如果不确切知道发生异常时服务器将向客户端发送什么,我们将无法为您提供帮助。基本上,除非服务器传递关于它是什么异常类的信息,否则JavaScript代码无法知道。如果是这样,那就是你的答案:使用响应中的信息。正如你所说的服务器异常是自定义的,那么你可以自定义它,在发送回客户端的异常消息中添加类名,并在错误块中显示。对3个变量
jqXHR使用浏览器调试器(或console.log),textStatus,errorThrown
查看您的异常类是否在其中任何一个类中。如果没有,那么您需要更改服务器以包含它,因为这是jquery/您必须处理的所有信息。您是否调试了
jqXHR
textStatus
errorshown
中的内容?