About Ajaxfileupload picture upload, success and error are triggered by the situation

Source: Internet
Author: User

Recently done project using jquery plug-in ajaxfileupload~~~

Encountered a very surprising thing, when the picture upload successfully (success), its error event is also triggered, the situation is:

Back-end data returned correctly

Front-end code is correct

The code is as follows:

  

1$ (document). On ("Change", ". Js_uploadfile ",function(){2Document.domain= "bookingctrip.com";//resolve picture upload cross-domain issues3     varajaxtimeout=$.ajaxfileupload ({4         //server-side address to handle file upload operations5Url:servicehost ("Boss") + '/upload/file/uploadcoverimg ',6Secureuri:false,//generally set to false7Fileelementid: "Js_uploadfile0",8timeout:10000,//time-out setting9DataType: ' JSON ',//Accept Data FormatTenData:formatjson (),//Uploading data content OneCrossdomain:true, ASuccessfunction(data) {//handler function when the server responds successfully -  
-Why do success and error all go?
theIn my various Baidu, after various attempts to find, ajaxfileupload this plugin, for the success callback function inside the JS error will not be in the console output
- //It's gone. It's an internal error exception capture mechanism, which can be answered by the console output within its source code . -How to solve this problem, that is to ensure that your success callback function will not have JS syntax error, good fault tolerance
-
+
A      }, atErrorfunction(data, status, E) {//handler function for server response failure - -
-
27
-
in
-
to + } - }) the})

About Ajaxfileupload picture upload, success and error are triggered by the situation

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.