0
我嘗試在AJAX中使這種形式爲「POST」,但我不加載用戶,當我在服務器上得到任何東西時,沒有任何建議?FormData不能與AJAX一起工作
這是形式
<form method="POST" action="/ajaxpost">
<input type="text" name="user"/>
<input type="submit" value="SEND"/>
</form>
//here trying to do the same form but ajax, I have this button that calls the function "sendAjax()"
<input type="submit" value="SEND"/>
//The function this does not work. fail data to the server
function sendAjax(){
// HTML5 form data object.
var fd = new FormData();
fd.append("user", 'JOAN FREDO USERNAME');
$.ajax({
url: '/ajaxpost',
data: fd,
contentType: 'application/x-www-form-urlencoded',
processData: false,
type: 'POST',
success: function(data){
alert(data);
}
});
}