CodingForums.com

CodingForums.com (http://www.codingforums.com/index.php)
-   JavaScript frameworks (http://www.codingforums.com/forumdisplay.php?f=62)
-   -   OO ajax requests in Prototype? (http://www.codingforums.com/showthread.php?t=151844)

vator 11-08-2008 03:10 PM

OO ajax requests in Prototype?
 
In my app I wanted to make ajax requests object oriented to make the code better. When I encountered a problem I found a framework called Prototype. My question is: Is what I'm doing in the code below covered in Prototype? Is it about making ajax requests OO? I guess there are a lot of other things as well since it's a framework. If it is I will try to use it instead of making my own...

I just need a short answer...

Code:

var u = "http://localhost:8080/Appname/autoGetCities.do?city=b";
var reqObj = new AjaxRequest(u);
var r = reqObj.getRequest();

function AjaxRequest(urlStr){
  var req;
  var url = urlStr;
  this.initRequest = initRequest;
  this.getRequest = getRequest;
 
  function getRequest(){
    req = this.initRequest();
    req.open("GET", url, false);
    req.onreadystatechange = this.onreadystate;
    req.send(null);

    return req;
  }

  function initRequest() {
    if (window.XMLHttpRequest) {
      return new XMLHttpRequest();
    } else if (window.ActiveXObject) {
      return new ActiveXObject("Microsoft.XMLHTTP");
    }
  }
}


Spudhead 11-10-2008 01:40 PM

The short answer is "yes". The long answer is here.


All times are GMT +1. The time now is 06:41 AM.

Powered by vBulletin®
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.