$.ajax({
type: 'POST',
url: 'http://localhost/php/chk.php',
data: formdata,
dateType: 'json',
success: function(resp) {
if ( resp == true ) { alert ('ok'); } else { alert ('not ok'); }
}
});
<form id="contact" action="#" method="post">
<input name="name" type="text"/>
<input name="email_address" type="text"/>
<textarea name="message"/></textarea>
<button id="submit">submit</button>
</form>
答案 0 :(得分:0)
如果formdata
应该是FormData
对象的实例,那么也许
你可以这样做
$.ajax({
type: 'POST',
url: 'http://localhost/php/chk.php',
data: ( new FormData( document.getElementById('contact') ) ),
dataType: 'json',
success: function( resp ) {
if ( resp == true ) { alert ('ok'); } else { alert ('not ok'); }
}
});