2
我想創建一個基於ajax的頁面,我可以從另一個php文件中調用一個表單,以便在用戶請求時顯示,並通過另一個Ajax提交表單數據。後面的過程很熟悉,但我對前者有些困惑。我該怎麼做?誰能幫忙?使用ajax顯示html表格
我想創建一個基於ajax的頁面,我可以從另一個php文件中調用一個表單,以便在用戶請求時顯示,並通過另一個Ajax提交表單數據。後面的過程很熟悉,但我對前者有些困惑。我該怎麼做?誰能幫忙?使用ajax顯示html表格
您可能試圖爲這個:
考慮一下:
的index.php(或其他文件,其中形式應該叫):
<!doctype html>
<head>
<script>
var xmlhttp=new XMLHttpRequest();
xmlhttp.onreadystatechange=function(){
if(xmlhttp.readyState==4&&xmlhttp.status==200){
document.getElementById("result").innerHTML=xmlhttp.responseText;
}
}
xmlhttp.open("GET", "form.php?id="+Math.random(), true);
xmlhttp.send();
function later_process(){//form submission here(since you are familiar.I may also provide it just give a comment.}
</script>
</head>
<body>
<div id="result"></div>
</body>
</html>
form.php的
/* No body/head/!doctype declarations */
<form method="post">
</form>