How can I make XMLHttpRequsts onreadystatechange a private method?

D

Daz

Hi all.

I would like to take the onreadystatechange method, and make it
private. Please could someone tell me what I need to do? I am guessing
I'd need to somehow copy the constructor of the XMLHttpRequest object,
into the prototype of an empty object and perhaps edit it from there?
I would appreciate it if anyone could give me a quick example of how I
might achieve this.

In case anyone is wondering why I would like to do something like
this, the reason is quite simple.

For my needs, onreadystatechange should be made private, and it will
be overridden by a function called onrequestcomplete. As I don't need
to know the various stages of the communication with the server, I
only want it to be passed to the external function for processing once
it's complete. The onrequestcomplete method will also handle any
errors the server might throw.

Needless to say, that I am looking to create a custom object and not
actually override anything on the original object itself.

Many thanks in advance.

Daz.
 
G

Geoffrey Summerhayes

Hi all.

I would like to take the onreadystatechange method, and make it
private. Please could someone tell me what I need to do? I am guessing
I'd need to somehow copy the constructor of the XMLHttpRequest object,
into the prototype of an empty object and perhaps edit it from there?
I would appreciate it if anyone could give me a quick example of how I
might achieve this.

In case anyone is wondering why I would like to do something like
this, the reason is quite simple.

For my needs, onreadystatechange should be made private, and it will
be overridden by a function called onrequestcomplete. As I don't need
to know the various stages of the communication with the server, I
only want it to be passed to the external function for processing once
it's complete. The onrequestcomplete method will also handle any
errors the server might throw.

Needless to say, that I am looking to create a custom object and not
actually override anything on the original object itself.

Many thanks in advance.

Daz.

Just write a wrapper class that has a request object as a
member, write what methods you need to expose, just
call the appropriate one on the request object with the same
arguments. If you need to expose properties use getters
and setters.
 
D

Daz

Just write a wrapper class that has a request object as a
member, write what methods you need to expose, just
call the appropriate one on the request object with the same
arguments. If you need to expose properties use getters
and setters.

I suspected that that might have been what I needed to do. In fact,
I've already done it, Hehe. I was just hoping that there might have
been a better way using less codes and possibly using overrides.

Many thanks for your response Geoff.
 
M

Matt Kruse

For my needs, onreadystatechange should be made private, and it will
be overridden by a function called onrequestcomplete.

Lots of ajax kits already do this, why re-invent the wheel?
My lib is at http://www.AjaxToolbox.com and might already be close to
what you're trying to accomplish.

Matt Kruse
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,754
Messages
2,569,528
Members
45,000
Latest member
MurrayKeync

Latest Threads

Top