本帖最后由 zmcici 于 2011-05-03 23:39:33 编辑

解决方案 »

  1.   

    页面肯定有,也执行了,有反回结果,就是返回结果总多出些<head></head><body>{0}</body>这样的信息,不同的浏览器,有不同的信息.上面的{0}中返回的是我想要的信息,其它都是多出来的
      

  2.   

    除了第一行,其它的html代码全部去掉
      

  3.   

    那就不要视图 直接调action 
     <form method="post" id="myForm" action="<%:Url.Action("AjaxCustoms")%>/" enctype="multipart/form-data">
    </form>  public ActionResult AjaxCustoms(FormCollection post)
            {           
         return Content("11.jpg");
            }
      

  4.   

    当然你还可以这样写  
    [HttpPost]
            public ActionResult AjaxCustom(FormCollection post)
            {           
                    HttpPostedFileBase files = Request.Files[0];
                    files.SaveAs(Server.MapPath("11.jpg");
                    return Json(new { success = "11.jpg", info = true });
            }<script src="../../Scripts/jquery-1.4.4.js" type="text/javascript"></script>
    <script src="../../Scripts/jquery-form-plugins-download.js" type="text/javascript"></script>
    <script type="text/javascript">
    $(document).ready(function () {
    $('#fileName').change(function () {
                $('#form0').ajaxSubmit(function (data) {
                    alert(data.success);
                });
                return false;
            });
     });
    </script>
    @using (Html.BeginForm("AjaxCustom", "Home", FormMethod.Post, new { enctype = "multipart/form-data", id = "form0", name = "form0" }))
    {
            <div>
            <input type="file" name="fileName" id="fileName" /> 
            </div>
     }
      

  5.   

    代码没看出问题,有可能是你引的js插件有问题换成<script src="@Url.Content("https://github.com/malsup/form/raw/master/jquery.form.js")" type="text/javascript"></script>
      

  6.   

    还真是这问题,害我取值后一直用一个隐藏DIV.innhtml=data; data=div.innertext 取出来。原来是JS问题