在通话过程中关闭浏览器时,ajax响应是什么? [英] What is the ajax response when closing the browser in the middle of a call?

查看:71
本文介绍了在通话过程中关闭浏览器时,ajax响应是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我发送了一个ajax请求,并且在服务器返回响应之前,用户关闭了浏览器,响应将如何处理?

If I send an ajax request, and before the response was returned by the server the user closed the browser, what happens with the response?

由于某种原因,由于浏览器已关闭,我不知道如何将其转到错误回调.

For some reason I get it to the error callback, though I can't understand how, since the browser is closed.

推荐答案

您可能想看看中止进度事件和随附的详细信息.浏览器很有可能以中止状态触发onreadystatechange处理程序. jQuery(或您使用的任何库)将假定请求失败并触发更高级别的错误处理程序.

You might want to look at the abort progress event and the accompanying gory details. It is highly likely that the browser will fire the onreadystatechange handler with abort as the state. jQuery (or whichever library you are using) will assume that the request failed and fire the higher level error handler.

这篇关于在通话过程中关闭浏览器时,ajax响应是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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