welcome every body
this is my first post
when i tried this code to accept multiple requests in ajax
http://javascript.about.com/library/blajax13.htm

it gives me error "get is not a function"
please help:)

Recommended Answers

have you defined the "XMLHttp.prototype.get" method?

Jump to Post

and you have linked the 2 files? (or alternatively have them in the single file?)

Jump to Post

All 5 Replies

have you defined the "XMLHttp.prototype.get" method?

XMLHttp.prototype.get = function(url) {
  self.open("GET", url, true)
  self.onreadystatechange = function() {
     self.processRequest();}
  self.send(null);}

thanks for trying 2 help
yes i define it look up

and you have linked the 2 files? (or alternatively have them in the single file?)

:) :( :'(
look i include a js file having this function

XMLHttp = function() {
  self = this;
  if (typeof XMLHttpRequest != 'undefined')
  return new XMLHttpRequest();
  else if (window.ActiveXObject) {
    var avers = ["Microsoft.XmlHttp", "MSXML2.XmlHttp", "MSXML2.XmlHttp.3.0",  "MSXML2.XmlHttp.4.0", "MSXML2.XmlHttp.5.0"];
    for (var i = avers.length -1; i >= 0; i--) {
      try {httpObj = new ActiveXObject(avers[i]);
      return httpObj;
      } catch(e) {}
    }
  }
  throw new Error('XMLHttp (AJAX) not supported');
}

XMLHttp.prototype.get = function(url) {
  self.open('GET', url, true);
  self.onreadystatechange = function() {
     self.processRequest();}
  self.send(null);
}

XMLHttp.prototype.processRequest = function() {
  if (self.readyState == 4) {
    if (self.status != 200) {
      self.resp = 'Error : Status '+this.status+' returned.';
    } else {
      if (cType == 'text/xml') {
    self.resp = 'xml';
      } else if (cType == 'text/plain') {
    self.resp = 'text';
      } else {
    self.resp = 'unknown content type';
      }
      this.response();
    }
  }
}

ajaxObj = XMLHttp();
ajaxObj.get('myrequest.php');

ajaxObj2 = XMLHttp();
ajaxObj2.get('myrequest.php');

ajaxObj.response = function() {
  if (self.resp == 'xml') {
    alert(self.responseXML);
  } else if (self.resp == 'text') {
    alert(self.responseText);
  } else {
    alert(self.resp);
  }
}
ajaxObj2.response = function() {
  if (self.resp == 'xml') {
    alert(self.responseXML);
  } else if (self.resp == 'text') {
    alert(self.responseText);
  } else {
    alert(self.resp);
  }
}

[I]then i call it [/I]

if (!ajaxObj) {
ajaxObj = XMLHttp();
ajaxObj.get('myrequest.php');
} else {
ajaxObj2 = XMLHttp();
ajaxObj2.get('myrequest.php');
}
ajaxObj.response = function() {
if (this.resp == 'xml') {
alert(this.responseXML);
} else if (this.resp == 'text') {
alert(this.responseText);
} else {
alert(this.resp);
}
}
ajaxObj2.response = function() {
if (this.resp == 'xml') {
alert(this.responseXML);
} else if (this.resp == 'text') {
alert(this.responseText);
} else {
alert(this.resp);
}
}

then it gives me :
ajaxobj.get is not a function

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.