3 回答

TA贡献1862条经验 获得超7个赞
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | var xhr = new XMLHttpRequest(); xhr.onreadystatechange = function(){ if(xhr.state == 4) { if((xhr.status >= 200 && xhr.status < 300) || xhr.status == 304) { console.log(xhr.responseText); } else { alert("HttpRequest was unsccessful: " + xhr.status); } } } xhr.open("post", "form.php", true); xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); var form = document.getElementById("info"); xhr.send(serialize(form)); |

TA贡献1806条经验 获得超8个赞
就和你普通的原生ajax一样啊。不过路径选择表单的action,提交方式选择表单的method对应的。然后用js将你的表单对应项的值都填写进入ajax的参数中。执行就好了。如果有文件域的话更麻烦点,好像要使用啥对象来着,你百度下,不太记得了,以前做过。
- 3 回答
- 0 关注
- 476 浏览
添加回答
举报