【jquery load】加载另一个页面中的表单后,点击提交按钮不能响应?该怎么解决
【jquery load】加载另一个页面中的表单后,点击提交按钮不能响应?
test.cpp
ajax.php
在test.php页面点击提交没任何反应,必填值为空也不提示。
在ajax.php正常。为什么会这样?
如果include "ajax.php“包含进来的话也正常
------解决思路----------------------
http://www.css88.com/jqapi-1.9/on/
------解决思路----------------------
<form>
document.form.submit();
你表单少了name属性值了吧,导致取不到表单对象报错了
<form name="form">,而且注意不要重名,要不就是集合了,集合没有submit方法
test.cpp
<html>
<head>
<script type="text/javascript" src="js/jquery.js"></script> // jquery库没问题
<script language="javascript">
$(document).ready(function(){
$('#dd').load('ajax.php'); // 含有表单
})
function Sub(){
document.form.submit();
alert("df");
}
</script>
</head>
<body>
<div id="dd"></div>
<?php
if($_GET){
$date = $_GET['n']; // 表单中的值
echo "$date";
echo "123";
}
?>
</body>
</html>
ajax.php
<div>
<table>
<form>
<th>
<td>姓名</td>
<td><input type="text" required="required" name="n"/></td>
</th>
<tr><td><input type="button" value="提交" onclick="Sub()"></td></tr>
</form>
</table>
</div>
在test.php页面点击提交没任何反应,必填值为空也不提示。
在ajax.php正常。为什么会这样?
如果include "ajax.php“包含进来的话也正常
------解决思路----------------------
$("#dataTable tbody").on("click", "tr", function(event){
alert($(this).text());
});
http://www.css88.com/jqapi-1.9/on/
------解决思路----------------------
<form>
document.form.submit();
你表单少了name属性值了吧,导致取不到表单对象报错了
<form name="form">,而且注意不要重名,要不就是集合了,集合没有submit方法