Google


ADBRITE ads links
You are here: CodeIdol.com > Ajax > Head Rush Ajax > She Blinded Me With Asynchronous > Creating Two Request Objects

SAVE
Digg
Shown on del.icio.us del.icio.us
See Whos Talking About This on Technorati Technorati
I've Reddit reddit

3.31. Creating two request objects

First, we need to actually create both request objects. Open up ajax.js and make the following changes, so that we're creating two request objects instead of just one:

This is your ajax.js file.

var request = null; We no longer
want to create a single request object. Delete this line.
function createRequest() { Now,
turn this code back into a function, so we can run it more than
once easily.
  var request = null;
  try {
    request = new XMLHttpRequest();
  } catch (trymicrosoft) {
    try {
      request = new ActiveXObject("Msxml2.XMLHTTP");
    } catch (othermicrosoft) {
      try {
        request = new ActiveXObject("Microsoft.XMLHTTP");
      } catch (failed) {
        request = null;
      }
    }
  }


  if (request == null) {
    alert("Error creating request object!");
  } else {
    return request;If the request object is created
    successfully, return it as the result of the function.
  }
}

var request1 = createRequest();
var request2 = createRequest(); Finally, in static
JavaScript, create two request objects. Assign each the return value of the
createRequest() function.
When this finishes running, you'll have two request objects-request1 and
request2-created and ready to use.


SAVE
Digg
Shown on del.icio.us del.icio.us
See Whos Talking About This on Technorati Technorati
I've Reddit reddit

You are here: CodeIdol.com > Ajax > Head Rush Ajax > She Blinded Me With Asynchronous > Creating Two Request Objects
   
Related tags







Popular Categories
Unix books and guides
AJAX popular information
C# language guides
Windows books and cookbooks
.......






© CodeIdol Labs, 2007