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

[Solved] cannot cancel an ajax request

5 Answers 145 Views
Ajax
This is a migrated thread and some comments may be shown as answers.
Aykut
Top achievements
Rank 1
Aykut asked on 14 May 2009, 04:34 PM
Hi
I have a radajaxloading panel with a cancel button in it which has a javascript event as

function AbortAllPostbacks() {
        var prm = Sys.WebForms.PageRequestManager.getInstance();
        prm.abortPostBack();
    }

Even if I click that button to cancel ajax the request ,
page gets a whole postback after some time and I lose my dynamically created controls in radajax panels.
How can I avoid this?
Is there a way to stop server side execution?
Thanks.

5 Answers, 1 is accepted

Sort by
0
Pavlina
Telerik team
answered on 15 May 2009, 12:52 PM
Hello Aykut,

You can cancel an AJAX request in the OnRequestStart client-side event handler of your RadAjaxManager/RadAjaxPanel.  Calling set_cancel(true) prevents the request from continuing.

You could review the following articles, which elaborates on this matter
Cancel AJAX request
Online Demo

Best wishes,

Pavlina
the Telerik team

 


Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Aykut
Top achievements
Rank 1
answered on 15 May 2009, 08:56 PM
Thanks for your reply but your scenario is for checking something on request start and cancel it if it doesn't meet the requirements.
Mine is, canceling an already started and ongoing ajax request. I need that for long running requests, user might want to change his/her parameters if the running query is very long.
Regards.

0
Pavlina
Telerik team
answered on 16 May 2009, 01:37 PM
Hello Aykut,

Note that when a an ajax request is performed, the page lifecycle is not affected. All events are fired and handlers are executed the same way as in case of regular postback. If you could cancel regular request to the server, you could do it the same way with ajax request.
 
Kind regards,
Pavlina
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Aykut
Top achievements
Rank 1
answered on 18 May 2009, 03:44 AM
So does this mean you cannot stop a request being returned to browser?
Any idea how the stop or cancel button of a browser works? Maybe I should imitate that.
Thanks for your help.
0
Pavlina
Telerik team
answered on 18 May 2009, 03:00 PM
Hello Aykut,

I am not sure how you could replicate the stop button functionality.
You could refer to the following link and see if this works for you:
http://forums.devshed.com/javascript-development-115/replicating-browser-stop-button-with-javascript-318994.html

Best wishes,
Pavlina
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
Ajax
Asked by
Aykut
Top achievements
Rank 1
Answers by
Pavlina
Telerik team
Aykut
Top achievements
Rank 1
Share this question
or