据我所知,Ajax.abort()
对于直接调用不起作用(看起来发送到服务器的请求与从服务器返回的请求不同,因为直接引擎在两者之间做自己的事情)。
虽然我不确定我是否直接回答你的问题,但我有一个类似的场景,解决方案是这样的:
/**
* A proxy class that ensures only the reponse to the last read request is
* processed.
*
* A quick user actions may result in more than one request sent to the server,
* but it is possible for the server to return a response to the second request
* before returning that of the first request. This will mean the the store
* will be populated with records that do not correspond to the latest user
* action.
*
*/
Ext.define('Ext.data.proxy.SerialDirect', {
extend: 'Ext.data.proxy.Direct',
alternateClassName: 'Ext.data.DirectSerialProxy',
alias: 'proxy.serialdirect',
doRequest: function(operation, callback, scope) {
this.callParent( arguments );
// Store the last read request
if ( operation.request.action == "read" ) {
this.lastReadRequest = operation.request;
}
},
processResponse: function(success, operation, request, response, callback, scope) {
// abort if the request is a read one and does not correspond to the
// last read request
if ( request.action == "read" && request != this.lastReadRequest )
return;
this.callParent( arguments );
}
});