onreadystatechange in object

J

Jacob Friis Larsen

Anyone know how to let processReqChange know that it is in an object?
In Php I can do it like this: array($this, 'function_name');

Any idea for a workaround?

/Jacob

function ajax () {

this.url = '';

this.getXML = getXML;
this.processReqChange = processReqChange;

function getXML () {
if (window.XMLHttpRequest) {
this.req = new XMLHttpRequest();
this.req.onreadystatechange = this.processReqChange;
this.req.open('GET', this.url, true);
this.req.send(null);
} else if (window.ActiveXObject) {
this.req = new ActiveXObject('Microsoft.XMLHTTP');
if (this.req) {
this.req.onreadystatechange = this.processReqChange;
this.req.open('GET', this.url, true);
this.req.send();
}
}
}

function processReqChange () {
if (this.req.readyState == 4) {
if (this.req.status == 200) {
alert('ok');
} else {
alert('There was a problem retrieving the XML data:' +
this.req.statusText);
}
}
}

}
 

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,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top