Error Handling
When an error occurs in an Ajax call, the result of the callback function parameter has an error attribute. This attribute is usually used to determine whether an error occurs.
Function Ondivcomplete (result)
{
// Alert (result. Error );
VaR MSG = "" ;
If (Result. Error ! = Null )
{
MSG + = ( " Exception: <br/> " );
MSG + = ( " Exception type: " + Result. Error. Type + " <Br/> " );
MSG + = ( " Exception information: " + Result. Error. Message + " <Br/> " );
MSG + = ( " Exception stack information: " + Result. Error. Stack + " <Br/> " );
MSG + = ( " Abnormal target site: " + Result. Error. targetsite + " <Br/> " );
MSG + = ( " Exception Source: " + Result. Error. Source + " <Br/> " );
Document. getelementbyid ( " MSG " ). Innerhtml = MSG;
}
}
You can also use the default processing function to provide a unified function for error handling.
Ajaxpro. onerror = Function (Error)
{
Alert ( " Error: " + Error. Message );
}
Timeout Processing
Ajaxpro. ontimeout = Function ()
{
Alert ( " Timeout " );
}
Loading Effect
Ajaxpro. onloading = Function (B ){
// Window. Status = B? "Loading ":"";
Document. getelementbyid ( " Loadingbar " ). Style. Display = B ? " Inline " : " None " ;
}
Note that the preceding three methods must be followed by four JS files loaded by ajaxpro; otherwise, an error occurs.
Server Cache [Ajaxpro. ajaxmethod]
[Ajaxpro. ajaxservercache ( 10 )] /* Cache result 10 s */
Public Datetime getservercachedtime ()
{
Return Datetime. now;
}