Skip to content

Instantly share code, notes, and snippets.

@lirongfei123
Created February 10, 2019 04:43
Show Gist options
  • Save lirongfei123/04e3fcc827444cdec57c67eb537f1308 to your computer and use it in GitHub Desktop.
Save lirongfei123/04e3fcc827444cdec57c67eb537f1308 to your computer and use it in GitHub Desktop.
ajax相关 #ajax
var formData = new FormData();
var name = $("input").val();
formData.append("file",$("#upload")[0].files[0]);
formData.append("name",name);
$.ajax({
url : Url,
type : 'POST',
data : formData,
// 告诉jQuery不要去处理发送的数据
processData : false,
// 告诉jQuery不要去设置Content-Type请求头
contentType : false,
beforeSend:function(){
console.log("正在进行,请稍候");
},
success : function(responseStr) {
if(responseStr.status===0){
console.log("成功"+responseStr);
}else{
console.log("失败");
}
},
error : function(responseStr) {
console.log("error");
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment