Cancel a request

7 posts, 0 answers
  1. arijit
    arijit avatar
    49 posts
    Member since:
    Jun 2012

    Posted 03 Mar 2010 Link to this post

    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
  2. Daniel
    Admin
    Daniel avatar
    4943 posts

    Posted 03 Mar 2010 Link to this post

    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. arijit
    arijit avatar
    49 posts
    Member since:
    Jun 2012

    Posted 03 Mar 2010 Link to this post

    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
  5. robertw102
    robertw102 avatar
    265 posts
    Member since:
    Jul 2007

    Posted 03 Mar 2010 Link to this post

    You should call args.set_cancel(true) to prevent the request from continuing.

    I hope that helps.
  6. arijit
    arijit avatar
    49 posts
    Member since:
    Jun 2012

    Posted 03 Mar 2010 Link to this post

    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.
  7. robertw102
    robertw102 avatar
    265 posts
    Member since:
    Jul 2007

    Posted 04 Mar 2010 Link to this post

    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.
  8. Daniel
    Admin
    Daniel avatar
    4943 posts

    Posted 08 Mar 2010 Link to this post

    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.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017