-
-
Save lirongfei123/04e3fcc827444cdec57c67eb537f1308 to your computer and use it in GitHub Desktop.
ajax相关 #ajax
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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