Codechef4u is a community for computer professionals,by computer professionals,just like you; who loves sharing and helping each others,Join them
Share your post


The jquery ajax method returns here ajaxRequest (a XMLHttpRequest) object, then this object with abort() method used to abort request. 


The XMLHttpRequest.abort() method aborts the request if it has already been sent. When a request is aborted, its readyState is changed to XMLHttpRequest.UNSENT (0) and the request's status code is set to 0.

Code example

In following code sample ajax post request used to remove user, to kill or abort request used abort() method at end.

//ajax request 
        var ajaxRequest = $.ajax({
            type: "POST",
           //MVC post call 
            url: '@Url.Action("RemoveUser","User")',
            data: { 'userId': userID },
            success: function (msg) {
                console.log("User deleted: " + msg);
 //kill the ajax request

That will abort the Ajax call, but on the Controller side what's happening?

If the controller is performing some long run calculation, is it possible to notify the controller to stop it since it's no longer needed?

I think you can use following in your requirement 


For more details check this stack overflow thread 

Share your answer

Share as a guest

Please subscribe me to the CodeChef4U.

By creating your new answer, you agree to the privacy policy and terms of service.