/*
* The source code for this program is not published or otherwise divested
* Its trade secrets.
*
*/
/** Ajax request encapsulation class
* Example:
* // Instantiate a request object
* Var ajaxobj = new ajaxproxyii ();
* // Set the URL of the Ajax request
* Ajaxobj. setrequesturl ("localhost/projectname/path/someaction. Action ")
* // Set the callback function. The callback function must have two parameters: somefunc (data, textstatus );
* Ajaxobj. setonsuccess (somefunc );
* // Set the parameter to be passed if the parameter is in the object format
* Ajaxobj. addparaobj (paraobject );
* // If the parameter is a key-value pair
* Ajaxobj. addparameter ("key", value );
* // Set asynchronous synchronization to asynchronous by default.
* Ajaxobj. setasync (false );
* // Send the request
* Ajaxobj. sendrequest ();
*/
VaR ajaxproxyii = function (){
This. Parameter = new object ();
This. pojopackagepath = "com. Taiyang. Search. Bean ";
This. _ props = new object ();
This. _ argarray = new array ();
This. _ pojoname = '';
This. _ parastr = '';
This. _ props ['asyn'] = true;
This. setpojoname = function (pojoname ){
This. _ pojoname = This. pojopackagepath + pojoname;
}
This. setrequesturl = function (URL ){
This. _ props ['url'] = URL;
}
This. setonsuccess = function (func ){
This. _ props ['onsuccess'] = func;
}
This. addparaobj = function (OBJ ){
This. _ argarray. Push (OBJ );
}
This. sendrequest = function (){
VaR callfunc = This. _ props ['onsuccess'];
This. setupparastr ();
$. Ajax ({
Type: 'post ',
URL: This. _ props ['url'],
Success: function (data ){
If (data. indexof ('errormessage')>-1 ){
VaR tmpobj = eval ('+ Data + ')');
If (tmpobj ['errorcode'] = "0 "){
VaR windowsarr = new array ();
Getwindowtop (window, windowsarr, tmpobj ['errormessage']);
Return;
} Else if (tmpobj ['errorcode'] = "1 "){
Window. Location. href = homeurl + "/error. jsp? Errormessage = "+ encodeuri (tmpobj ['errormessage']);
Return;
}
}
Callfunc (data );
},
Data: This. _ parastr,
Async: This. _ props ['asyn'],
Error: function (data, textstatus ){
// Alert ("error" + data );
}
});
}
This. setparastr = function (STR ){
This. _ parastr = STR;
}
This. addparameter = function (Key, value ){
This. Parameter [''+ key] = value;
}
This. setasync = function (FLAG ){
This. _ props ['asyn'] = flag;
}
This. setupparastr = function (){
If (this. _ pojoname! = 'Undefined' & this. _ pojoname! = ''){
This. _ parastr + = '& pojoname =' + this. _ pojoname + '& jsondata = ';
This. _ parastr + = JSON. stringify (this. _ argarray );
}
For (VAR I = 0; I <this. _ argarray. length; I ++ ){
This. _ argarray [I] = NULL;
}
For (var p in this. Parameter ){
This. _ parastr + = P + '=' + this. Parameter [p] + '&';
}
// This. _ parastr = "garbled"
// This. _ parastr = encodeuri (this. _ parastr );
}
}