Ajax Talk - Asynchronous javascript and xml discussion board
 FAQ   Search    Usergroups      Register   Profile   Check your messages   Log in 
Signup now to enjoy a range of free membership advantages !!
Ajax Talk - Moderators Wanted
wrap xmlhttp object in our own js class

 
Post new topic   Reply to topic    Ajaxtalk.com Forum Index -> AJAX Help
View previous topic :: View next topic  
Author Message
rajika
New one
New one


Joined: 09 Oct 2006
Posts: 2

PostPosted: Mon Oct 09, 2006 3:48 am    Post subject: wrap xmlhttp object in our own js class Reply with quote

hello
I am trying to wrap the xmlhhtp object in a another javascript class.That is I have defined a function wshttprequest and within this I create the xmlhttp object.I could override the methods (sucn as send ,open etc) but I was unble to override the PROPERTIES in xmlhttp object and define my own propties in wshttp class. Can any one help me
Thanks
rajika
Back to top
View user's profile Send private message
Snyke
Forum Assistant
Forum Assistant


Joined: 20 Jun 2006
Posts: 87
Location: Zurich

PostPosted: Mon Oct 09, 2006 5:55 am    Post subject: Reply with quote

Any code? It would be much easier to answer ^^
_________________
[::[ Snyke.net ]::]
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
rajika
New one
New one


Joined: 09 Oct 2006
Posts: 2

PostPosted: Mon Oct 09, 2006 7:48 am    Post subject: code Reply with quote

here is the code snyke, thanks for your help


function WSHttpRequest(){

//function delclarations
this.test = test;

// create the xmlhttp object
var xmlhttp = false;
try {
xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
} catch (E) {
xmlhttp = false;
}
}
if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
try {
netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserRead");
xmlhttp = new XMLHttpRequest();
} catch (e) {
xmlhttp=false;
}
}
if (!xmlhttp && window.createRequest) {
try {
xmlhttp = window.createRequest();
} catch (e) {
xmlhttp = false;
}
}


// here it went wrong the properties says undifined , i am unable to override them
// properties
this.onreadystatechange = xmlhttp.onreadystatechange;
this.readyState = xmlhttp.readyState;
this.responseText = xmlhttp.responseText;
this.responseXML = xmlhttp.responseXML;
this.status = xmlhttp.status;
this.statusText = xmlhttp.statusText;

WSHttpRequest.prototype.set = function(param){
onreadystatechange = param;
}

// wshttp object mehods
// the abort method
WSHttpRequest.prototype.abort = function(){
xmlhttp.abort();
}

// get response headers
WSHttpRequest.prototype. getAllResponseHeaders= function(){
xmlhttp.getAllResponseHeaders();
}

WSHttpRequest.prototype.getResponseHeader = function(headerLabel){
xmlhttp.getResponseHeader(headerLabel);
}


// the open method
WSHttpRequest.prototype.open = function(method,URL,asnycFlag,username,password){
xmlhttp.open(method,URL,asnycFlag,username,password);
}

// the send method
WSHttpRequest.prototype.send = function(content){
xmlhttp.send(content);
}

// the set request method
WSHttpRequest.prototype.setRequestHeader = function(label, value){
xmlhttp.setRequestHeader(label, value);
}

// the API which differniate WShttp object and XMLhttp object
//

}


Note:following is the test page when I create a object from the WShttp class the methods works as I need.But when I need to check the value of getAllResponseHeaders() mehods it doesn't works.And also the wshttp.readyState never comes to 4.It always says 0 (the object uninilized) that is the problem I have .Thanks for help
<html>
<head><title>WSHttpRequest</title>
<script type="text/javascript" src="WSHttpRequest.js"></script>
</head>
<body>
<script type="text/javascript" >
function test(){
var wshttp = new WSHttpRequest();
netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserRead");
wshttp.open("HEAD","http://localhost/index.html",true);

wshttp.onreadystatechange = function() {
if (wshttp.readyState == 4) {
alert(wshttp.getAllResponseHeaders())
}
}
alert("The state is " + wshttp.readyState);
wshttp.send(null);


}

</script>
</body>
<input type="button" value="test" onclick="test()">
</html>
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Ajaxtalk.com Forum Index -> AJAX Help All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
 Advertisements
 XML & Copyright Notice 
    


Powered by phpBB © 2001, 2005 phpBB Group

What is according to Wikipedia: Ajax Web2.0 XML E4X


Link to our site:

  


del.icio.us digg spurl wists simpy newsvine blinklist furl blogmarks yahoo! myweb smarking ma.gnolia segnalo reddit fark technorati cosmos


Normal Bookmark


Partner Button Links:
Codecrunch.com: Webmaster Tutorials    One Ajax


Partner Text Links:
quomon | web20log | ajaxmatters | tableless | 456bereastreet | music charts | gift ideas | competitions | free xbox 360 | link trade ?


Credits:
it consultancy & project management lead generation zoekmachine optimalisatie steal these buttons seo expert