JQuery.form.js plugin does not solve the connection timeout (timeout) reason Analysis and solution _jquery

Source: Internet
Author: User

JQuery.form.js is a form plugin that supports AJAX form submission and Ajax file uploads.

When you recently submitted a form that contains files using Jquery.form.js, you have a problem: when you run into a slow speed, and we set up timeout, for example:

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

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

At this point, we do not have a callback function to handle the error, and the example of Baidu is the only two callback functions:

Beforesubmit:showrequest,//Pre-submit callback function 
Success:showresponse,//Submit callback function

So, I go to the official Website View API, official website: http://malsup.com/jquery/form/#options-object, sure enough to find the callback function that handles the error:

The error
Callback function to is invoked upon error.

So that's what my options say:

var options = {
beforesubmit:showrequest,//Pre-submit callback function 
Success:showresponse,//Post successful callback function 
error: ShowError,///Post error callback function
timeout:3000//Limit request time, jump request when request is greater than 3 seconds

This is what the callback function says:

function ShowError (responsetext, statustext) {
if (statustext== ' timeout ') {
layer.msg ("Server busy, please try again later!") ", {icon:5,time:1500});
return;
}

The above is a small set to introduce JQuery.form.js plug-ins can not solve the connection timeout (timeout reason analysis and solutions, I hope to help you, if you have any questions please give me a message, small series will promptly reply to everyone. Here also thank you very much for the cloud Habitat Community website support!

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.