1) Script Title: Basic Ajax Routine (get & post)

2) Script URL (on DD): http://www.dynamicdrive.com/dynamici...jaxroutine.htm

3) Describe problem:

Hi,

I am using the basic ajax routine (the post) to call a php-generated xml file that backs up user-entered text to a backup file. My quandry is how to abort the ajax call if it fails in, say, 4 seconds. What's the most efficient way to abort this? Is it important to officially abort the request?

Here is what I have tried.
Code:
//Define call back function to process returned data
function processGetPost()
  {
    var myajax=ajaxpack.ajaxobj;
   
    if(some_variable == 'true') //  -> because some condition has been met...
       {                               //       such as a javascript timer....
          //  MY ATTEMPT HERE TO ABORT 
           myajax.abort();
       }

    var myfiletype=ajaxpack.filetype
  
 if (myajax.readyState == 4)
  { //if request of file completed
     // if request was successful or running script locally
     if (myajax.status==200 || window.location.href.indexOf("http")==-1)
       { 
         if (myfiletype=="txt")
            alert(myajax.responseText)
         else
           {
             //  do something........
           } //else
        }
   }
}

After initiating this intentionally doomed request ( ), I have used this code to see if the XMLHttpRequest is really dead. When I initiate this function, I continue to get an alert that ajaxpack.ajaxobj is still alive. I get this alert:

ajaxpack: [object XMLHttpRequest]
Here's my alert function:

Code:
function show_ajax_req()
  {
 
    alert("ajaxpack: " + ajaxpack.ajaxobj);
 
    //  TRYING TO CONFIRM THAT IT HAS BEEN ABORTED....
   //   I DO NOT GET A CONFIRMATION HERE...
    if(!ajaxpack.ajaxobj)
      alert("ajax killed..");        
  
  }

Thanks for any suggestions!