IT Community - Software Programming, Web Development and Technical Support

How do we stop the ajax request?

This is a discussion on How do we stop the ajax request? within the PHP Programming forums, part of the Web Development category; hi all, I have two seperate php pages. 1. main.php, 2. result.php main.php have div tag , ok &...


Go Back   IT Community - Software Programming, Web Development and Technical Support > Web Development > PHP Programming

Register FAQ Members List Calendar Mark Forums Read
  #1 (permalink)  
Old 07-17-2007, 05:00 AM
raj raj is offline
D-Web Programmer
 
Join Date: Jul 2007
Posts: 89
raj is on a distinguished road
Default How do we stop the ajax request?

hi all,

I have two seperate php pages.

1. main.php, 2. result.php

main.php have div tag , ok & cancel button & ajax function, div tag for display the result from result.php page.

result.php only return some string for display when its call by ajax function.


if i click the ok button then it will call the ajax function
, then ajax function send to http request to result.php & waiting request for result.php ?
after getting request from result.php -> show the result to main.php (ajax doing this functionality generally)


i want to stop the ajax http request:
- user click ok button then ajax function will be call, that time user immediately click the cancel button that ajax request should be terminate,

is it possible?

Last edited by raj : 07-17-2007 at 05:12 AM.
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 07-20-2007, 05:20 AM
kathir kathir is offline
D-Web Trainee
 
Join Date: Feb 2007
Posts: 25
kathir is on a distinguished road
Default Re: How do we stop the ajax request?

hi raj,
yes... possible

Ajax request can be possible to cancel by manually.
This bellow code may helpfull for your requirement.

<script>
var isSent = false;
Http = new getHTTPObject(); // create XMLHTTPRequest object

function sendRequest()
{
Http.open("GET", URL, true);
Http.onreadystatechange = function() { /* Response processer */ }
Http.send(null);
isSent = true;
}

function stopRequest()
{
if(isSent) Http.abort();
return;
}
</script>
Thanks
-Kathir
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 07-22-2007, 10:39 PM
Jeyaseelansarc Jeyaseelansarc is offline
D-Web Genius
 
Join Date: Mar 2007
Location: Chennai
Posts: 1,162
Jeyaseelansarc is on a distinguished road
Send a message via AIM to Jeyaseelansarc
Default Re: How do we stop the ajax request?

Hi,
Because AJAX is normally processed asynchronously we may have situations where we want to stop waiting for the responce to come back from the server because it is no longer relevant.

If u want to stop the Ajax request process, you can manually call as Kathir said
obj.abort().
__________________
With,
J. Jeyaseelan

Everything Possible
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
how to use ajax in asp.net and how to install ajax in my system vel.m8 ASP and ASP.NET Programming 5 04-08-2008 08:55 PM
New Topic head request prasannavigneshr Discussweb HQ 6 02-10-2008 03:04 AM
what is change request, how u use it? Shanthi Software Testing 1 11-16-2007 04:33 AM
Suppose server object is not loaded into the memory, and the client request for it , oxygen Java Programming 1 07-27-2007 04:15 AM
New Topic head request Karpagarajan Discussweb HQ 2 07-16-2007 07:32 AM


All times are GMT -7. The time now is 05:32 PM.


Copyright ©2004 - 2007, DiscussWeb. All Rights Reserved.

SEO by vBSEO 3.0.0