摧毁窗口后如何处理传入的ajax请求? [英] How to handle incoming ajax requests after destroying window?

查看:159
本文介绍了摧毁窗口后如何处理传入的ajax请求?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建一个包含发送ajax请求的网格的窗口。现在,我立即关闭窗口,然后网格完全创建并且ajax请求返回。

I create a window containing grids that send off ajax requests. Now, I immediatley close the window again before the grids are fully created and the ajax requests return.

我有两个问题:


  • 窗口中的组件在销毁窗口后仍然活着

Chrome控制台列出它们。虽然我的窗口有 autoDestroy:true 在窗口关闭后,网格面板和存储仍然存在。关闭时, destroy 事件触发。文件说,窗口下的所有组件都应该被销毁。

Chrome console lists them. Although my window has the autoDestroy: true the gridpanel and store are still existing after the window is closed. When closed, the destroy event is fired. Docs say, all components under the window should be destroyed.


  • 然后我的回调最终返回并被执行,但窗口被销毁>
  • Then my callbacks finally return and get executed but the window is destroyed

问题是,回调尝试重新配置没有更多商店附加的网格。

The problem is, that the callbacks try to reconfigure a grid that has no more store attached.

错误:未捕获TypeError:无法调用方法'getCount'为null Table.js:500 / lib / extjs / src / view /Table.js

如果我的窗口被销毁,我该如何阻止回调处理?

How can I stop the callbacks from processing if my window is destroyed?

推荐答案

使用 mon ,以便在侦听对象被破坏时被删除,或者您可以:

Registering the events with mon so that they get removed when the listening object get destroyed. Alternatively you may:


  • 在destroy()方法中手动删除它们

  • 在回调范围内检查可能不存在的方法或属性ip他们

修改

一些你可以做的事情


  1. 检查网格的destroy()方法是否被调用

  2. 通过调用 中止所有请求Ext.Ajax.abortAll() (窗口关闭之前)

  3. 仅通过调用 Ext.Ajax.abort(request) (之前的窗口关闭)

  1. check if the destroy() methods of the grids get called
  2. abort all request by calling Ext.Ajax.abortAll() (before the window close)
  3. abort just specific requestst by calling Ext.Ajax.abort(request) (before the window close)

我建议使用选项2.因为它应该是最安全的。

I recommend to use option 2. because it should be the safest.

编辑2

要查看所有正在运行的请求,您需要查看私人请求属性 Ext.data.Connection Ext.Ajax 扩展。 请求是类型对象,并将包含当前正在运行的每个请求的属性(请求ID)。

To take a look at all running request you need to look at the private requests property of Ext.data.Connection from which Ext.Ajax extend. requests is of type object and will contain a property (the request Id) for each request that is currently running.

这篇关于摧毁窗口后如何处理传入的ajax请求?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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