Question

In my application I have many ajax request that executes every now and then. I have one that executes with a settimeout another is with a user interaction. My problem is the user interaction part.

The scenario is when the user sets the parameter and clicks the button it executes a ajax request. If he makes a mistake with its parameter the user will adjust something and then execute again the ajax request, with the previous request still on going.

I want to abort the previous request without using the abortall() because like I said before there are other request that should not be interrupted. So its like selecting a request to abort. How do I do that? Please Help.

Was it helpful?

Solution

There is a property on Ext.Ajax autoAbort : Boolean

Whether a new request should abort any pending requests.

Defaults to: false

Available since: 1.1.0

set this prop to true on your Ajax sent by user, so it will not interfere with setInterval ajax's. Also, make sure that you have a client side and a server side validation, so bad params will be avoided. Solving bad params on client side is much quicker, cheaper and user friendly thing to do than let user submit falsy data!

Ext.Ajax.request({
    url: '/echo/json/',
    params: {
        id: 1
    },
    autoAbort : true, 
    success: function(response){        
          //do something
    },
    failure:function(response){
         //do something
    }
});

Here is example on fiddle!

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top