就和你普通的原生ajax一样啊。不过路径选择表单的action,提交方式选择表单的method对应的。然后用js将你的表单对应项的值都填写进入ajax的参数中。执行就好了。如果有文件域的话更麻烦点,好像要使用啥对象来着,你百度下,不太记得了,以前做过。
1234567891011121314varxhr=newXMLHttpRequest();xhr.onreadystatechange=function(){if(xhr.state==4){if((xhr.status=200xhr.status300)||xhr.status==304){console.log(xhr.responseText);}else{alert("HttpRequestwasunsccessful:"+xhr.status);}}}xhr.open("post","form.php",true);xhr.setRequestHeader("Content-Type","application/x-www-form-urlencoded");varform=document.getElementById("info");xhr.send(serialize(form));
创建对象、调用
~
~
~