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