Resolves that the returned JSON result data cannot be obtained when using the Ajaxfileuploder plugin

Source: Internet
Author: User

When using the Ajaxfileuploader plugin in an MVC project, when uploading a picture or a file, the JSON data is returned in the controller, but in IE, or in the Googlechrome browser, there is a return JSON data download, in this case, the following is my own Ways to solve the problem:

Special attention needs to be paid to two places:

1. When returning the JSON data, add the "text/html" parameter

return Json (new                {                    true,                    = originfilename,                    = GUID,                     = min,                    = Max                },"text/html");

2. This method of Uploadhttpdata:function (R, type) in Ajaxfileuploader.js is modified as follows:

            data = eval ("data =" + data);            /*++++++++++++++ the  following is the modified code  ++++++++++++++++++++++++++*/            var datastr = r.responsetext;            var newdatastr = datastr.replace ("<pre>", ""). Replace ("</pre>", "");            data = Newdatastr;            /*+++++++++++++++ the  following is the modified code ++++++++++++++++++++++++++*/

3. When the Ajaxfileupload method is called on the front-end, the returned JSON string is converted to a JSON object when the callback method success:

Success:function (DA) {            //alert ("Success");            Alert (DA);            var aaa = Json.parse (DA);            alert (aaa.success);            alert (Aaa.max);            alert (!aaa.success);             if (!aaa.success) {                 alert (aaa.error);             } else {                 //alert ("AAA");                 $ (' #imgshow '). Show ();                 $ (' #imgshow '). Append (" ');                 $ ("#" + Modelimgid). Val (Aaa.max);             }        ,

This will be possible, when uploading images, if the upload is successful, you can preview the correct

Resolves that the returned JSON result data cannot be obtained when using the Ajaxfileuploder plugin

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.