<form method="post" action="test.php">
...
<input type="submit" />
</form>
通过表单
方式提交表单数据后,整个页面刷新,URL变成test.php。var xhr = new XMLHttpRequest();
xhr.open("post", "test.php", true);
xht.setRequestHeader("Content-type","application/x-www-form-urlencoded");
xhr.send(...);
通过AJAX方式提交表单数据,只得到了test.php返回的数据,不会刷新整个页面,浏览器地址栏中URL不变。
那么,如果我的页面中没有表单
,但要向服务器test.php页面提交数据,并刷新整个页面,浏览器地址栏中URL变成test.php,新页面中有根据提交的数据生成的数据,该怎么做呢?