简体   繁体   中英

jQuery ajax issue on IE9

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...

Try

return Json(new { Data = new { message = outputFilePathResponse } }, "text/html");

Reference: IE tries to download JSON in ASP. NET MVC 3

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM