Solve the problem that AjaxSubmit prompts downloading files when uploading files under IE. ajaxsubmit uploads files

Source: Internet
Author: User

Solve the problem that AjaxSubmit prompts downloading files when uploading files under IE. ajaxsubmit uploads files

Springmvc backend:

@ RequestMapping (value = "scoreFileUpload", produces = "text/html; charset = UTF-8") @ ResponseBody public String upload (HttpSession session, @ RequestParam ("file1") MultipartFile file, @ RequestParam ("paperId") String paperId, HttpServletRequest request) {// obtain the id of the logon user Integer userId = (Integer) session. getAttribute (BaseConstant. SESSION_UERID_KEY); JSONObject json = new JSONObject (); if (request instanceof MultipartHttpServletRequest) {// get the file name of the uploaded file String fileName = file. getOriginalFilename (); String subfix = FileUtils. getFileExtend (fileName);} return "";}

Js: Terminal

$ ('# FileForm '). submit (function () {var _ businessDetailId = $ ("# businessDetailId "). val (); var _ paperId = $ ("# paperId "). val (); var url = "scoreFileUpload? PaperId = "+ _ paperId +" & businessDetailId = "+ _ businessDetailId; var optionss = {dataType:" text/html ", type: 'post', url: url, // beforeSubmit: showRequest, complete: showResponse, clearForm: false, timeout: 3000000}; // submit the form $ (this ). ajaxSubmit (optionss );//!!! Important !!! // To prevent normal browsers from submitting forms and generating page navigation (to prevent page refreshing ?) Return false;}); <pre name = "code" class = "javascript"> function showResponse (data) {data = JSON. parse (data. responseText); if (data. type! = Null ){}}

If the returned type is json, this problem occurs only in ie, and chrome and firefox are normal. To solve the problem, only text/html is returned.
The type returned by the backend cannot be json, but text/html. Then, the returned type is converted to json.

The above section describes how to solve the problem that AjaxSubmit prompts you to download files under IE. I hope it will help you. If you have any questions, please leave a message for me, the editor will reply to you in a timely manner. Thank you very much for your support for the help House website!

Related Article

E-Commerce Solutions

Leverage the same tools powering the Alibaba Ecosystem

Learn more >

Apsara Conference 2019

The Rise of Data Intelligence, September 25th - 27th, Hangzhou, China

Learn more >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

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: and provide relevant evidence. A staff member will contact you within 5 working days.