我有輸入型文本這樣如何通過ajax post發送值輸入類型文本?
<input type="text" id="test" value="">
,我有AJAX功能後這樣。
$(document).ready(function() {
$('#summernote').summernote({
height: 300, // set editor height
minHeight: null, // set minimum height of editor
maxHeight: null, // set maximum height of editor
focus: true, // set focus to editable area after initializing summernote
callbacks: {
onImageUpload: function(files) {
sendFile(files[0]);
}
}
});
function sendFile(file, editor, welEditable) {
document.getElementById("loading_upload_threads_image").style.display = "block";
data = new FormData();
data.append("file", file);//You can append as many data as you want. Check mozilla docs for this
$.ajax({
data: data,
type: "POST",
url: "threads_image_upload.php",
cache: false,
contentType: false,
processData: false,
success: function(url) {
$('#summernote').summernote('editor.insertImage', url);
document.getElementById("loading_upload_threads_image").style.display = "none";
}
});
}
});
我想知道如何從id="test"
值發送到我的AJAX的帖子?
它應該已經在你的表單數據中,但要確保你使用formData()調用形式:'new formData($('form')[0])''。您是否觀看過瀏覽器開發人員工具中的AJAX請求/響應?你有沒有在項目中包含jQuery庫?是否有任何錯誤報告?你在網絡服務器上運行這個嗎? –
@JayBlanchard OP創建一個空的FormData對象 –
Ack! ()#RoryMcCrossan –