I am using the jQuery form plugin in my MVC project to upload images.
Image loading works fine in Chrome and firefox, however, when it comes to IE 8.
Not like Chrome, instead of returning json data that is later consumed by the post-submit callback, in IE 8 it returns a txt file and asks if you want to download. and in the side of the txt file, this is json data.
couldn't understand where i did something wrong, any ideas?
early.
The code is placed in a separate js file: upload.js
(function ($) { ImageUploader = function (o) { var options = { success: showResponse, // post-submit callback url: "/Image/ImageUpload", // override for form 'action' attribute type: "post", // 'get' or 'post', override for form 'method' attribute dataType: 'json', // 'xml', 'script', or 'json' (expected server response type) clearForm: true // clear all form fields after successful submit }; o.ajaxForm(options); $("input#file").change(function () { o.submit(); }); // post-submit callback function showResponse(responseText, statusText, xhr, $form) { .... } }; })(jQuery);
on the watch page:
$(document).ready(function () { ImageUploader($("#ajaxUploadForm")); });
source share