ajxa非同步傳輸檔案
阿新 • • 發佈:2018-11-09
<form id="form1">
<input type="file" name="file" />
</form>
<div class="click">
提交
</div>
<script type="text/javascript">
$('.click').click(function(){
var formData = new FormData($( "#form1" )[0]);
$.ajax({
url: './uploadclass.php' ,
type: 'POST',
data: formData,
async: false,
cache: false,
contentType: false,
processData: false,
success: function (returndata) {
alert(returndata);
},
error: function (returndata) {
alert(returndata);
}
});
})
</script>
<input type="file" name="file" />
</form>
<div class="click">
提交
</div>
<script type="text/javascript">
$('.click').click(function(){
var formData = new FormData($( "#form1" )[0]);
$.ajax({
url: './uploadclass.php' ,
type: 'POST',
data: formData,
async: false,
cache: false,
contentType: false,
processData: false,
success: function (returndata) {
alert(returndata);
},
error: function (returndata) {
alert(returndata);
}
});
})
</script>