jquery.form.js的$.ajaxSubmit

$.ajax只提交form以文本方式,如果异步提交包含<input type="file">上传是传过不过去,需要使用jquery.form.js的$.ajaxSubmit

$("#imgForm").ajaxSubmit({
  url:"/user/updateImg.json",
  type: "post",
  dataType : "json",
    beforeSend:function(){
    alert(1)
  },
  complete:function(){
    alert(2)
  },
  success:function(data){
    if(data.success){
      $("#img").attr("src",data.data);
    }else{
      alert(data.resultMessage);
    }
  }
})

posted @ 2017-03-01 17:08  年轻就是财富!  阅读(93)  评论(0)    收藏  举报