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

Cancelling an ajax request via user interaction

2 Answers 64 Views
Ajax
This is a migrated thread and some comments may be shown as answers.
Pivetal
Top achievements
Rank 1
Pivetal asked on 26 Sep 2008, 09:07 AM

We have the following scenario:

A user  selects a node from a tree on the left hand side, we then use the information from the node to populate the right hand side using:

function PerformAjaxRequest(i_Val)

                {  

                    $find("<%= MasterAjaxManager.ClientID %>").ajaxRequest(i_Val);                        

                }

Where MasterAjaxManager is a RadAjaxManager. My problem is that when a user then selects multiple nodes on the tree in quick succession, the right hand side becomes out of sync with the actual node selected on the tree. Hence I would like to cancel the request. The method I have observed for cancelling an request I have seen is the following:

function onRequestStart(sender, arguments)
{

return false;

}

In the onRequestStart function I would then poll a variable (delay in between each poll) which will tell me if another node has been selected if so the function will return false else carry on polling until either a timeout has been reached or the ajaxRequest has been successful.

I am contacting your team to see if there is a better way of doing this???

Many Thanks in Advance

Bleddyn

2 Answers, 1 is accepted

Sort by
0
Sebastian
Telerik team
answered on 29 Sep 2008, 10:30 AM
Hello Bleddyn,

Indeed this seems to be a possible solution for your particular scenario - feel free to use it if viable for your configuration. Also please have in mind that you can cancel the ajax request from within the OnRequestStart handler of the ajax manager according to the ASP.NET AJAX conventions:

function onRequestStart(sender, arguments)  
{  
  arguments.set_cancel(true);  
}  
 

An alternative approach would be to implement ajax request queueing as discussed in this documentation topic.

Best regards,
Stephen
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Pivetal
Top achievements
Rank 1
answered on 29 Sep 2008, 10:37 AM
thnaks for your reply, ajax request queueing is just what I was looking for!
Tags
Ajax
Asked by
Pivetal
Top achievements
Rank 1
Answers by
Sebastian
Telerik team
Pivetal
Top achievements
Rank 1
Share this question
or