Creating two request objects






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.



 Python   SQL   Java   php   Perl 
 game development   web development   internet   *nix   graphics   hardware 
 telecommunications   C++ 
 Flash   Active Directory   Windows