Ajaxpro New Discovery (4): Zero collection

Source: Internet
Author: User
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;
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.