form里既有數(shù)據(jù)也有圖片上傳js代碼: <script type="text/javascript">
$(document).ready(function(){ //DOM的onload事件處理函數(shù)
$("#send").click(function(){ //當(dāng)按鈕button被點(diǎn)擊時(shí)的處理函數(shù)
postdata(); //button被點(diǎn)擊時(shí)執(zhí)行postdata函數(shù)
});
});
function postdata(){ //提交數(shù)據(jù)函數(shù)
$.ajax({ //調(diào)用jquery的ajax方法
type: "post", //設(shè)置ajax方法提交數(shù)據(jù)的形式
url: "sendmes.php", //把數(shù)據(jù)提交到sendmes.php
dataType: "json",//返回?cái)?shù)據(jù)類型
data: $("#send_form").serialize(),
});
}
</script>html form:<form id="send_form" enctype="multipart/form-data">
<textarea name="message" id="msg"></textarea>
<input type="file" name="upload" id="upload">
<input type="submit" class="send" id="send" value="發(fā)布">
</form>
現(xiàn)在就只能把textarea里的信息post到后端,圖片上傳不了,該怎么解決呢?
qq_遁去的一_1
2023-04-16 18:14:27