这让我发疯了。
当我提交没有JS的表单时它运行良好,但是当我将带有jQuery Ajax的表单提交到.asp页面时,我没有收到任何错误,但它没有检索任何值。
形式:
<form id="form-elenco-messaggi" method="post" action="/admin/admin_messaggi.asp" enctype="multipart/form-data">
....some input fields...
<button name="action" type="submit" value="MarkAsRead" class="submitFomActions">Mark as read</button>
</form>
JS执行AJAX请求:
var urlAjaxPage= '/messaggi-ajax.asp';
$('body').on('click', '#form-elenco-messaggi .submitFomActions', function(e){
var action = $(this).val(); //get the button value
var formData = new FormData($('form#form-elenco-messaggi')[0]);
formData.append('action',action); //append button value to formData
$.ajax({
type: "POST",
url: urlAjaxPage,
data: formData,
async: false,
cache: false,
contentType: false,
processData: false,
error: function () {
alert("error");
},
success: function (response) {
alert(response); //here it should show 'action' value from .asp response.write request.form("action")
console.log(response);
}
});
return false;
});
这些是控制台日志:
Headers reply
Cache-Control private
Content-Length 0
Content-Type text/html
Date Tue, 20 Sep 2016 16:15:35 GMT
Server Microsoft-IIS/5.0
Headers request
Accept */*
Accept-Encoding gzip, deflate
Accept-Language it-it,it;q=0.8,en-us;q=0.5,en;q=0.3
Connection keep-alive
Content-Length 484
Content-Type multipart/form-data; boundary=---------------------------251902054217998
有什么想法吗?