adis0099 adis0099 - 2 months ago 7
Ajax Question

Extjs ajax request is returning in a disorderly manner

My application performs a code for query.
The user enters the 3947 code.

For each type a query 3, 39, 394 and 3947.
But as the request is asynchronous, there is sometimes the last to arrive before others.
So it happens that the last record returned is 394 instead of 3947

How to ensure that the last appointment will come last?

listeners: {
change: function (sender, newValue, oldValue, eOpts) {
loadData();
}


}

Answer

In a simplified way you could ignore all requests and perform only the last in this way:

listeners: {
    change: function (sender, newValue, oldValue, eOpts) {
        if (call_request) clearTimeout(call_request);       
        call_request = setTimeout(loadData, 750);
}}