This is a migrated thread and some comments may be shown as answers.

Cancel a request

6 Answers 131 Views
Ajax
This is a migrated thread and some comments may be shown as answers.
arijit
Top achievements
Rank 1
arijit asked on 03 Mar 2010, 11:45 AM
I want to cancel a ajax request from a javascript function. I tried the following, did not work

    var requestInProgress;  
 
    function OnRequestStart(sender, args) {  
        requestInProgress = args.XMLHttpRequest;          
    }  
 
    function ResetRequest() {  
        requestInProgress.abort();  
    } 

i want to cancel the request and hide the loading panel from ResetRequest() function.
Please help

Regards
Arijit Chatterjee

6 Answers, 1 is accepted

Sort by
0
Daniel
Telerik team
answered on 03 Mar 2010, 01:00 PM
Hello Arijit,

I recommend you try this approach:
<script type="text/javascript">
   function onRequestStart(sender, args)
   {
       if (something)
           args.set_enableAjax(false);
   }
</script>

Export from ajaxified grid

Regards,
Daniel
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
arijit
Top achievements
Rank 1
answered on 03 Mar 2010, 04:04 PM
No, I don't want to decide the cancel before submit. I want to cancel it after the submit.
So this is not helpful in my case. please suggest.

Regards
0
robertw102
Top achievements
Rank 1
answered on 03 Mar 2010, 09:15 PM
You should call args.set_cancel(true) to prevent the request from continuing.

I hope that helps.
0
arijit
Top achievements
Rank 1
answered on 04 Mar 2010, 02:17 AM
I have already written that I will cancel the request from another javascript function, see my first post.
Then how i will get that args ?
It is not helpful.
0
robertw102
Top achievements
Rank 1
answered on 04 Mar 2010, 02:51 PM
Where would you be calling the ResetRequest method from? Isn't it OnRequestStart? If so why not pass the args from that method to your ResetRequest method.
0
Daniel
Telerik team
answered on 08 Mar 2010, 06:29 PM
Hello Arijit,

The OnRequestStart event is the latest point where you can cancel the request on the client.

Regards,
Daniel
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Tags
Ajax
Asked by
arijit
Top achievements
Rank 1
Answers by
Daniel
Telerik team
arijit
Top achievements
Rank 1
robertw102
Top achievements
Rank 1
Share this question
or