相关疑难解决方法(0)

IE尝试在ASP中下载JSON.NET MVC 3

我试图从我的动作返回Json,之后IE试图下载并向我显示保存对话框.我在Firefox中测试过它,它运行正常.

return Json(new { success = false, message = ex.Message }, "application/json");
Run Code Online (Sandbox Code Playgroud)

这种行为的原因是什么?如何解决这个问题?

之后在Javascript部分我试试这个

 if (responseJSON.success == false) {
                        alert(responseJSON.message);
                        cancel();
                    }
Run Code Online (Sandbox Code Playgroud)

但IE无论如何都不会显示警报.它带给我保存对话框.

我试图改变"application/json""text/plain"和保存对话框消失了,但我无法看到的警报呢.我错过了什么?

编辑:

这是我的complect Javascript,我使用Valums qquploader(ex-Ajaxupload)来上传图像

 var uploader = new qq.FileUploader({
                element: document.getElementById("image-upload"),
                action: '/Home/ImageUpload',
                allowedExtensions: ['jpg', 'png', 'gif'],
                sizeLimlit: 2048,onComplete: function (id, fileName, responseJSON) {
                    if (responseJSON.success == false) {
                        alert(responseJSON.message);
                        cancel();
                    }
                    else {
                         alert("success");
                          //some code here
                        }
                     }
                   });
Run Code Online (Sandbox Code Playgroud)

我已经alert("success");在我的其他部分进行了测试并转发了json "text/plain",之后我看到了警报.但在那个时候responseJSON.success != false对我来说.你有什么建议吗?

javascript asp.net-mvc json asp.net-mvc-3

12
推荐指数
2
解决办法
8111
查看次数

标签 统计

asp.net-mvc ×1

asp.net-mvc-3 ×1

javascript ×1

json ×1