令我郁闷之极的javascript错误--Object error

出于项目需要,应用了ajaxfileupload.js,Jquery插件之一,部分js代码如下
                $.ajaxFileUpload({
                   url: "UpLoadTemplte.aspx",
                    secureuri: false,
                   fileElementId: "upfileInput",
                    dataType: "json",
                   success: function(data,status){
                        if(data.Flag=="1")
                        {
                         $("#divmsg").html(""+data.Msg);

          $("#loading_msg").html("");
                        }
                    },
                    error: function (data, status, e)
                    {
                     alert("上传失败:"+e.toString());
                    }
               })};

提交页面是UpLoadTemplte.aspx,主要是保存上传文件,返回数据类型是json,页面服务器端主要代码如下:

 protected void Page_Load(object sender, EventArgs e)
    {

     try
                 {       
              HttpFileCollection uploadFiles = Request.Files;//上传文件集合
              HttpPostedFile theFile = uploadFiles[0];//获取上传Excel文件  
                   theFile.SaveAs(toFile);
                     Response.Write("{ Flag:'1', Msg:'文件上传成功', Filename:'" + fileName + "', OriFileName:'" + oname + "' }"); 
                 }
                 catch 
                 {
                        Response.Write("{ Flag:'1', Msg:'文件上传失败', Filename:'0' , OriFileName:'" + oname + "' }");
                 }finally

      {

      Response.End();

      }

}

一看貌似没有问题,运行时候就是object error的错误,由于js调试没有掌握,vs2005断点调了半天也找不到问题,最后找到一个人家用

ajaxfileupload.js做的一个Demo,仔细对比了一下,发现缺少了一句及其不起眼的Response.End();靠。。。。晕。。。

转载于:https://www.cnblogs.com/conan87810/archive/2009/03/10/1407869.html

你可能感兴趣的:(runtime,javascript,json)