Entonces quedaría algo como:
Código javascript
:
Ver original...
...
// request public method
this.request = function()
{
var t = this;
var a = new xmlhttp(); // get xmlhttp object
var b = setHeader(t.method, t.charset); // set get/post different headers
setQuery(t); // construct get/post different properties
t.onRequest(); // Method to do before all process
a.open(t.method, t.page, t.async); // open ajax petition
a.setRequestHeader('Content-Type', b); // set headers ALWAYS after OPEN
getState(t, a); // ajax reponse state
};
...
...
...
// private method to set ajax petition state
var getState = function(t, a)
{
if(t.async)
{
a.onreadystatechange = function() // get petition changestates
{
switch (a.readyState) {
case 1: // if readystate is 1 The request has been set up
t.onSetUp();
break;
case 2: // if readystate is 2 The request has been sent
t.onSend();
break;
case 3: // if readystate is 3 The request is in process
t.onProcess();
break;
case 4: // if readystate is 4 the request is complete
reqResponse(t, a);
break;
}
};
a.send(t.query); // send get/post query
}
else
{
a.send(t.query); // send get/post query
reqResponse(t, a);
}
};
...
...