How To Extend Xmlhttprequest Object In Javascript?
I would like to extend the existing XMLHttpRequest object so that it should work with all the browsers. Now i have been trough with JS inheritance and things however before startin
Solution 1:
Don't do this. XMLHttpRequest
is a host object and you should not try to extend it. To quote Kangax:
Next problem with DOM extension is that DOM objects are host objects, and host objects are the worst bunch. By specification (ECMA-262 3rd. ed), host objects are allowed to do things, no other objects can even dream of. To quote relevant section :
Host objects may implement these internal methods with any implementation-dependent behaviour, or it may be that a host object implements only some internal methods and not others.
This also means that host objects may disallow extension by using prototype
.
However, as Kangax also advices, you can create a wrapper around XMLHttpRequest
and do whatever you like with it.
Post a Comment for "How To Extend Xmlhttprequest Object In Javascript?"