Javascript 无法获取$u post[“SearchSubmit”值 在这里搜索 名字 姓 出生日期 地址 最后传递标准 最后发送百分比 最后一年 $('document').ready(函数(){ $('#log').load('searchresult.php'); }); //$('#log').load('searchresult.php'); $('document').ready(函数(){ $('#log').load('studentList.php'); }); //$('#log').load('studentList.php');
上面提到的是我的代码,但我不能在我当前的php页面中加载任何日志文件。 我还打印了Javascript 无法获取$u post[“SearchSubmit”值 在这里搜索 名字 姓 出生日期 地址 最后传递标准 最后发送百分比 最后一年 $('document').ready(函数(){ $('#log').load('searchresult.php'); }); //$('#log').load('searchresult.php'); $('document').ready(函数(){ $('#log').load('studentList.php'); }); //$('#log').load('studentList.php');,javascript,php,jquery,mysql,forms,Javascript,Php,Jquery,Mysql,Forms,上面提到的是我的代码,但我不能在我当前的php页面中加载任何日志文件。 我还打印了$\u POST['SearchSubmit']我得到的是空值。 我只想得到,如果搜索框已填充,那么将加载搜索结果,否则将加载学生列表。 请帮助解决此问题。一切正常。但您没有为表单分配操作。请设置与操作相同的页面名称。假设您的页面名称为myform.php。然后action=“myform.php”。如果您使用php,请坚持使用它 <form class="form-inline" id="form1" me
$\u POST['SearchSubmit']
我得到的是空值。
我只想得到,如果搜索框已填充,那么将加载搜索结果,否则将加载学生列表。
请帮助解决此问题。一切正常。但您没有为表单分配操作。请设置与操作相同的页面名称。假设您的页面名称为myform.php。然后action=“myform.php”。如果您使用php,请坚持使用它
<form class="form-inline" id="form1" method="post" role="form" action="">
<div class="from-group">
<label for="usr">Search Here</label>
<input id="search" name="search" class="form-control" placeholder="Enter the First Name">
<input type="submit" class="btn btn-success" name="SearchSubmit" value="GO" />
</div>
<div>
<a class="btn btn-primary" href="logout.php">LOGOUT</a>
</div>
</form>
<?php var_dump($_POST['SearchSubmit']); ?>
<table class="table text-info">
<tr>
<th class="text-center">First Name</th>
<th class="text-center">Last Name</th>
<th class="text-center">Date of Birth</th>
<th class="text-center">Address</th>
<th class="text-center">Last Passout Standard</th>
<th class="text-center">Last Passout Percentage</th>
<th class="text-center">Last Passout Year</th>
</tr>
<tbody id="log"></tbody>
</table>
<script type="text/javascript" language="javascript">
<?php if($_POST['SearchSubmit']){ ?>
$('document').ready(function() {
$('#log').load('searchresult.php');
});
//$('#log').load('searchresult.php');
<?php } ?>
$('document').ready(function() {
$('#log').load('studentList.php');
});
//$('#log').load('studentList.php');
</script>
dfk您将php与javascript混用,为什么?您的php if语句缺少php开始和结束标记。我知道了,我是php的初学者,所以我犯了那个错误。这更多的是一个注释,而不是一个回答完全有效(对w3c无效,但浏览器接受此)
<?php if(isset($_POST['SearchSubmit'])){
include 'searchresult.php';
} else {
include 'studentList.php';
}?>