Including the source code of the myeclipse project:
 
Http://download.csdn.net/detail/flyuniverse_shell/4144288
 
 
 
This program can be familiar with Ajax, please refer to the following code:
 
VaR net = new object (); // defines a global variable. net
Net. ajaxrequest = function (URL, onload, onerror, method, Params) {// create a constructor
This. Req = NULL;
This. onload = onload;
This. onerror = (onerror )? Onerror: This. defaulterror;
This. loaddate (URL, method, Params );
}
 
Net. ajaxrequest. Prototype. loaddate = function (URL, method, Params ){
If (! Method ){
Method = "get ";
}
If (window. XMLHttpRequest ){
This. Req = new XMLHttpRequest ();
} Else if (window. activexobject ){
This. Req = new activexobject ("Microsoft. XMLHTTP ");
}
If (this. req ){
Try {
VaR loader = this;
This. Req. onreadystatechange = function (){
Net. ajaxrequest. onreadystate. Call (loader );
}
This. Req. Open (method, URL, true );
// This. Req. Send (Params );
This. Req. Send (null );
} Catch (ERR ){
This. onerror. Call (this );
}
}
}
 
Net. ajaxrequest. onreadystate = function () {// refactor the onreadystate Function
VaR Req = This. req;
VaR ready = Req. readystate;
If (ready = 4 ){
If (req. Status = 200 ){
This. onload. Call (this );
} Else {
This. onerror. Call (this );
}
}
}
 
Net. ajaxrequest. Prototype. defaulterror = function () {// default error handling function
Alert ("error fetching data! "
+ "\ N \ nreadystate:" + this. Req. readystate
+ "\ Nstatus:" + this. Req. Status
+ "\ Nheaders:" + this. Req. getAllResponseHeaders ());
}