ASP. NET MVC uses jquery.form.js asynchronous uploads the return value in IE is changed to a download solution

Source: Internet
Author: User

Error logging:

<script type= "Text/javascript" > $ (Function () {$ (document). Off ("Ajaxsend");                    Asynchronously uploads $ ("#Submit"). Click (function () {if ("#selectFileButton"). val () = = "") {                return false; } $ ("#fileForm"). Ajaxsubmit ({success:function (msg, status) {h                        Idemask (); if (msg = = "") {msg = "Upload succeeded!                            ";                        $ ("#selectFileButton"). Val ("");                            } else {var regex = new RegExp ("\" "," G ");                            msg = Msg.replace (Regex, "");                        msg = Msg.replace (/\|/g, "<br>");                    } document.getElementById (' Uploadmessage '). InnerHTML = msg;                }                });                Showmask (); return false;        Do not refresh the page});    }); &Lt;/script> 

As the code above, asynchronously uploads the page. The values returned are displayed on the page in the Chrome browser. But under IE8 (the project needs to test only IE8), the return value becomes the download.

The reason for the query, which eventually locates on the response head that is returned asynchronously.

In response head here, Content-type is Application/json and will be downloaded under IE8.

Workaround:

            var rs = Json (                message = message            );            Rs. ContentType = "text/html";            Return RS;        

such as the red font in the code above.

In the method that is returned asynchronously, the content-type of the response head that modifies the return value is text/html

ASP. NET MVC uses jquery.form.js asynchronous uploads the return value in IE is changed to a download solution

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.