0
當我點擊「提交第二個」時,頁面會轉到first.html。我想它去second.html在表單中提交表格
的index.html
<body onload="secondForm();">
<script type="text/javascript">
function ajaxRequest(){
var activexmodes=["Msxml2.XMLHTTP", "Microsoft.XMLHTTP"] // activeX versions in IE
if (window.ActiveXObject){ // test support for ActiveXObject in IE
for (var i=0; i<activexmodes.length; i++){
try{
return new ActiveXObject(activexmodes[i])
}
catch(e){
// suppress
}
}
}
else if (window.XMLHttpRequest) // mozilla,safari,chrome,opera
return new XMLHttpRequest()
else
return false
}
function secondForm(id) {
var mygetrequest=new ajaxRequest()
mygetrequest.onreadystatechange=function() {
if (mygetrequest.readyState==4) {
if (mygetrequest.status==200 || window.location.href.indexOf("http")==-1) {
document.getElementById("secondForm").innerHTML=mygetrequest.responseText
}
}
}
mygetrequest.open("POST", "secondForm.html, true)
mygetrequest.send(null)
}
</script>
<form method="POST" action="first.html" id="firstForm">
<span id="secondForm"></span>
<input type="submit" value="Submit First">
</form>
secondForm.html
<form method="POST" action="second.html" id="secondForm">
<input type="submit" value="Submit Second">
</form>
這些ajax調用中的任何一個被調用?此外,您打算如何執行此代碼?你也有2件事情用id'secondForm',你不能有2件東西在DOM中具有相同的ID,它需要是唯一的 – Neal 2011-05-20 12:17:26
你使用jquery還是可以使用它,如果推薦 – 2011-05-20 12:17:53
它在
– reefine 2011-05-20 12:18:45