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>