Go Back   CodingForums.com > :: Client side development > JavaScript programming > JavaScript frameworks

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 11-08-2008, 03:10 PM   PM User | #1
vator
New to the CF scene

 
Join Date: Aug 2008
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
vator is an unknown quantity at this point
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");
    }
  }
}

Last edited by vator; 11-08-2008 at 03:13 PM..
vator is offline   Reply With Quote
Old 11-10-2008, 01:40 PM   PM User | #2
Spudhead
Senior Coder

 
Spudhead's Avatar
 
Join Date: Jun 2002
Location: London, UK
Posts: 1,856
Thanks: 8
Thanked 110 Times in 109 Posts
Spudhead is on a distinguished road
The short answer is "yes". The long answer is here.
Spudhead is offline   Reply With Quote
Users who have thanked Spudhead for this post:
tosbourn (11-14-2008)
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 02:36 PM.


Advertisement
Log in to turn off these ads.