AjaxSubmit solves the problem of successfully uploading and saving the json file. ajaxsubmitjson
The customer requested to upload the file and process the returned results in js. It was found that ajaxform is quite useful, and there was no problem in firefox testing,
However, the execution in IE browser prompts me to save the json file without using the success method. On the Internet, I have to set the type of the returned format to text/html, but I still cannot pass it.
Then I tried the latest version on the official website and introduced my latest js execution. The higher version is better, the compatibility is better, the BUG rate is low, and a js version is provided,
Convenient for everyone to download http://download.csdn.net/detail/hsliwei/7917853
JQueryformjs uses ajaxForm and ajaxSubmit to submit a form to upload a file. After the server returns json data, the IE browser cannot parse the file.
Forum.jquery.com/..-in-ie
Hi, I also encountered a problem when I used jQuery's ajaxSubmit for upload. I don't know how to solve it.
When the ajaxSubmit API submits a form, if a file is uploaded in the form, it determines whether the iframe parameter configured is set to false. If not, it creates a hidden iframe to submit the form, if iframe is set to false, you can determine whether the browser supports the HTML5 fileAPI. If the browser supports fileAPI, you can directly submit the file in XHR mode. Otherwise, the file is submitted as a normal form.
Therefore, because the form submitted by iframe is hidden, if the server returns "application/json" data, IE and Chrome download files by default, because the content is returned to iframe, instead of the success method of ajaxSubmit. After iframe loads the returned results, the success method of ajaxSubmit reads the iframe content and converts it to a json object.
The solution is to add a parameter in the configuration of the ajaxSubmit submission form, and the server determines whether the form is submitted by ajaxSubmit. If yes, the content of the "text/html" type is returned, if not, "application/json" is returned.
To put it simply, if ajaxSubmit uploads a file, the returned content can only be webpage content; otherwise, a download prompt box may appear in IE.