Ajax-url不工作-Pl帮助我 $.ajax({ 键入:“POST”, 网址:'http://localhost/php/chk.php', 数据:formdata, 日期类型:“json”, 成功:功能(resp){ if(resp==true){alert('ok');}else{alert('notok');} } }); 提交

Ajax-url不工作-Pl帮助我 $.ajax({ 键入:“POST”, 网址:'http://localhost/php/chk.php', 数据:formdata, 日期类型:“json”, 成功:功能(resp){ if(resp==true){alert('ok');}else{alert('notok');} } }); 提交,php,Php,如果formdata应该是formdata对象的实例,那么 你可以这样做 $.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'); } } }

如果
formdata
应该是
formdata
对象的实例,那么 你可以这样做

$.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>

什么是
formdata
?你所说的
url不工作是什么意思
请去学习如何提问。$。ajax({type:'POST',url:'',data:(new-FormData('#contact')[0]),dataType:'json',success:function(resp){if(resp==true){alert('ok');}else{alert('notok');} });
$.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'); }
   }
});