有没有人Ajax请求过程中曾经成功地查获未捕获的异常? [英] Has anyone ever successfully tracked down uncaught exception during ajax request?

查看:118
本文介绍了有没有人Ajax请求过程中曾经成功地查获未捕获的异常?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何阿贾克斯知道它是否成功还是失败,如果服务器端不回应任何东西?

How do ajax know whether it failed or succeeded if server side doesn't echo anything back?

$.ajax(error:..,success:..)

我在我的测试遇到了这个异常:

I met with this exception in my test:

未捕获的异常:[异常...   组件返回故障code:   0x80040111(NS_ERROR_NOT_AVAILABLE)   [nsIXMLHtt prequest.statusText]   nsresult:0x80040111   (NS_ERROR_NOT_AVAILABLE)的位置:   JS框架::    HTTP://localhost/script/tab.js ::   匿名::第69行的数据:无]

uncaught exception: [Exception... "Component returned failure code: 0x80040111 (NS_ERROR_NOT_AVAILABLE) [nsIXMLHttpRequest.statusText]" nsresult: "0x80040111 (NS_ERROR_NOT_AVAILABLE)" location: "JS frame :: http://localhost/script/tab.js :: anonymous :: line 69" data: no]

在服务器端code是:

The server side code is :

$id = process();

和测试的目的,我的退出()的过程中();

And for the purpose of testing,I have exit() in process();

时,对于该异常的原因是什么?如果是,为什么?

Is that the reason for this exception?If so,why?

修改 我看了看,以引起异常的行,它是$。阿贾克斯()的错误处理功能

EDIT I looked over to the line that cause exception,it's the error handling function of $.ajax()

error:function(XMLHttpRequest, textStatus, errorThrown){ 
    alert(XMLHttpRequest.statusText);alert(textStatus);alert(errorThrown);
}

这里有什么问题?

Anything wrong here?

推荐答案

在HTT prequest还返回一个状态,如200 == OK,没有发现404 == 12152 ==连接关闭了服务器等.. 刚读了状态ID是什么,他们的意思是让你可以找他们。你也可以用于调试原因,只写了myhtt prequest.status到文档,它表明它返回什么样的地位。

The httprequest also returns a status such as 200 == ok, 404 == not found, 12152 == connection closed by server and so on.. Just read up on the status id's what they mean so you can look for them. you can also for debugging reasons just write out myhttprequest.status to the document and it shows what status it returned.

这篇关于有没有人Ajax请求过程中曾经成功地查获未捕获的异常?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆