IE tries to download json response while submitting jQuery multipart form data containing file

后端 未结 9 670
别那么骄傲
别那么骄傲 2020-12-14 15:03

I\'m trying to submit a form with a file field in it via jQuery.Form plugin, here\'s the code:

$(\'form\').ajaxSubmit({
  url: \"/path\",
  data         


        
9条回答
  •  青春惊慌失措
    2020-12-14 15:08

    I have not found a direct solution to this, but I eventually implemented the following workaround: I used dataType: "text" in my ajax settings and then returned plaintext from controller, separating values with ; and parsing them on the client side. That way IE and Forefox stopped trying to download a response.

    I did not find any other way to prevent said behavior other then to return plaintext. I tried returning JSON as plaintext and then parsing it with $.parseJSON, but it didn't work due to some js errors.

提交回复
热议问题