Reputation: 9621
I am using this plugin to let users upload images trough ajax.
To create the uploader and trigger a post this jQuery function is used:
function createUploader() {
var uploader = new qq.FileUploader({
element: document.getElementById('file-uploader'),
allowedExtensions: ['pdf'],
multiple: false,
action: '@Url.Action("AjaxUpload", "Upload")',
onComplete: function(id, fileName, responseJSON){
window.location.href = responseJSON.message;
}
});
}
Well, in responseJSON.message
I am returning the path where the file was uploaded (actually converted) and I am doing a trick with window.location.href
to force the browser to show the user DOWNLOAD box for that file.
This works great on FF and Chrome but on IE it says:
Do you want to open or save AjaxUpload from localhost?
And if you press open, instead of getting the file from the specified location, you actually get a file containing responseJSON message.
Any jQuery guru who can give me a clue for this issue?
UPDATE: What I can confirm is that the issue is not with window.location.href = responseJSON.message;
because even if I remove this line and put alert('something')
the same problems occurs...so instead of parsing onComplete
, IE try to open the JSON response...
Upvotes: 3
Views: 2678
Reputation: 4320
Try
return Json(new { Data = new { message = outputFilePathResponse } }, "text/html");
Reference: IE tries to download JSON in ASP. NET MVC 3
Upvotes: 5