html:
<div class="col-sm-4">
<input class="form-control font-size-style" id="mydatalist" name="mydatalist" type="text" list="platformlist" placeholder="Select a platform...">
<datalist id="platformlist">
<option>aa</option>
<option>bb</option>
<option>cc</option>
<option>cc</option>
<option>ee</option>
</datalist>
</div>
Javascript:
$(document).ready(function() {
$('#myForm').on('submit', function(e) {
e.preventDefault(); // 阻止表单默认提交行为
var formData = new FormData()
var mydatalist= document.getElementById('mydatalist').value;
formData.append('mydatalist',mydatalist)
$.ajax({
type: 'POST',
url: '/xxxx', // 提交到的URL
headers:{'X-CSRFToken':'{{csrf_token}}'},
data: formData,
contentType:false,
processData: false,
success: function(response) {
..
},
error: function(xhr, status, error) {
..
}
});
}
});
}