开发者

ExtJS: ajax call on keystroke not working while another call is existant

So I have a situation where there is an ajax call made after a keystroke (with buffer:150). If (for whatever reason) the ajax call is slightly laggy to return, keypress during that load process fail to make another call.

The component is a tree using a loader for the data. And is setup as follows:

tree config

....
root:{
    nodeType:'async',
    text:'Accounts',
    expanded:false,
    uiProvider:false
},
loader: {
    dataUrl:'dataurl',
    baseParams:{},
    loadexception:function(){
        console.log('Failed to load QUICKSEARCH');
    }
}
....

with the following on a text field

textfield listener

....
listeners:{
keyup:{buffer:150, fn:function(f, e) {
    if(Ext.EventObject.ESC == e.getKey()) {
        field.onTriggerClick();
    }else{
    var val = this.getRawValue();
            thisTree = this.ownerCt.ownerCt;
            thisTree.loader.baseParams.quicksearch_string = val;
           开发者_开发问答 thisTree.root.reload();
    }
}}
}
....

Ideally, I want to be able to cancel (either completely cancel, or cancel listening for the response) the call and start the new one.

So I guess there should actually be a question in here somewhere...So is there a way to cancel listening for a previously made ajax call or a setting to force a newer call


Try an alternative way of reloading the tree. Here is another syntax I have seen.

thisTree.getLoader().load(thisTree.root);


Here what your looking for is asynchronous ajax calls.

This is possible, although it is important to remember that these calls will not necessarily return in any given order, so it is only acceptable to use these when the order of return does not matter. (Although, you can work around this, it will get complicated).

In order to accomplish this (dynamically) you should have a function which uses a series of incremental iframes, and thus the algorithm is the following:

If(document.getElementById('iframe1').isDone()){ iframe1.src = newSrc }else{ iframe2.src = newSrc }

These will BOTH be able to run and return asynchronously. This functionality can also be put into a dynamic loop, allowing any number of asynchronous iframe calls, but you'll have to use google for that!

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜