Jquery.form.js Resolution for connection Timeout (timeout) cannot be resolved

Source: Internet
Author: User

When I recently submitted a form that contains files using jquery.form.js, I ran into a problem: when we hit a slow speed and we set up timeout, for Example:

var options = {      timeout:3000  // limit request time, when request is greater than 3 seconds, jump out  of request }  

Our page will die here and post the results returned by the F12 developer Tool:

At this point, we do not handle the error callback function, and Baidu came out of the example of only these two callback functions:

Beforesubmit:showrequest,//pre-commit callback function
Success:showresponse,//post-commit callback function

so, I went to the official website to view the api, official Website: http://malsup.com/jquery/form/#options-object, and sure enough, I found the callback function to handle the error:

Error function to is invoked upon Error.

So my options are written like this:

var options = {       beforesubmit:showrequest,  // pre-commit callback function         success : showresponse,      // Post successful callback function          error:showerror,            //post-commit Error callback function
timeout:3000 // limit the request time, when the request is greater than 3 seconds, jump out of the request
}

The callback function is written like this:

function showerror (responsetext, Statustext) {        if(statustext== ' timeout ') {             Layer.msg ("the server is busy, please try again Later!") ", {icon:5,time:1500});             return ;        }}

This is my solution, do not know the solution to your problem did not?

Jquery.form.js Resolution for connection Timeout (timeout) cannot be resolved

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.