到目前为止,我有这个表格
<form id = "newpost" enctype="multipart/form-data">
<input type = "text" id = "post_title" name = "post_title" placeholder = "Post Title"/>
<textarea id = "post_txt" name = "post_txt" placeholder = "Post Text"></textarea>
<input type = "file" id = "file_upload" name = "file_upload"/></br>
<input type = "submit" value = "Post" id = "newpost_btn" name = "newpost_btn"/>
</form>
和这个脚本
var serializedData = $form.serialize();
$.ajax({
url: "submit.php",
type: "post",
data: serializedData
});
但上述脚本仅适用于文本。那么有没有办法在一个请求中传递文本和图像?