AjaxFileUpload 插件是一个很简洁很好用的上传文件的插件,可以实现异步上传功能,但是在 ASP.NET MVC中使用时,会出现上传图片后不能正确的显示的问题,经过仔细排查,终于找到原因,解决方法如下:

 uploadHttpData: function (r, type) {

        var data = !type;
       // var data = r;
        data = type == "xml" || data ? r.responseXML : r.responseText;

        // If the type is "script", eval it in global context
        if (type == "script")
            jQuery.globalEval(data);
        // Get the JavaScript object, if JSON is used.
        if (type == "json")
        {
            // eval("data = " + data);
            /*++++++++++++++以下为新增代码++++++++++++++++++++++++++*/
            var datastr = r.responseText;
            var newdatastr = datastr.replace("<pre>", "").replace("</pre>", "");
            data = JSON.parse(newdatastr);

            /*+++++++++++++++以上为新增代码++++++++++++++++++++++++++*/

        }
        // evaluate scripts within html
        if (type == "html")
            jQuery("<div>").html(data).evalScripts();

        return data;
    },
View Code

相关文章:

  • 2022-12-23
  • 2021-10-28
  • 2021-06-30
  • 2021-09-11
  • 2021-05-29
  • 2022-12-23
  • 2021-08-18
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-03-08
  • 2022-03-04
  • 2021-11-25
  • 2022-01-28
  • 2021-08-03
相关资源
相似解决方案