我的ajax页面成功运行,但当我点击搜索按钮时,它会重定向到我的登录页面或默认页面。在不使用ajax的其他页面上,我的搜索按钮工作并显示结果。我试图克服这些问题,但它仍然给我同样的错误。
的index.php:
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script>
<script>
$(document).ready(function(){
// Set trigger and container variables
var trigger = $('#nav a'),
container = $('#content');
// Fire on click
trigger.on('click', function(){
// Set $this for re-use. Set target from data attribute
var $this = $(this),
target = $this.data('target');
// Load target page into container
container.load(target + '.php');
// Stop normal link behavior
return false;
});
});
</script>
<!-- Optimize for mobile devices -->
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<!-- MAIN CONTENT -->
<div id="content">
<?php include ('home.php');?>
</div> <!-- end content -->
<div class="clear"></div>
<!-- FOOTER -->
<div id="footer">
<div class="menu">
<nav id="nav">
<br><br><br><br><a href="#" data-target="home">Muka Depan |</a>
<a href="#" data-target="page_1">Status Kerosakan |</a>
<a href="#" data-target="page_2">Carian Mudah |</a>
<a href="#" data-target="page_3">Pautan Pantas </a><br><br>
</nav>
</div>
</div> <!-- end footer -->
<div class="clear"></div>
home.php:
<form action="checklogin.php" method="POST" id="login-form" class="cmxform" autocomplete="off">
</p>
<p>
<label>Nombor Personel</label>
<input type="text" id="login-username" class="round full-width-input" placeholder="Isi Nombor Personel" name="username" autofocus />
</p>
<p>
<label>Kata Laluan</label>
<input type="password" id="login-password" name="password" placeholder="Isi Kata Laluan" class="round full-width-input" />
</p>
<center><a href="forget_pass.php" class="button ">Terlupa Kata Laluan?</a>
<br><input type="submit" class="button round blue image-right ic-right-arrow" name="submit" value="LOG MASUK" />
<input type="reset" class="button round blue" name="reset" value=" PADAM" /></center>
</fieldset>
</form>
page_2.php:
<form action="" method="post" name="search">
Nombor Personel <input name="searchtxt" type="text" class="round my_text_box" placeholder="Isi nombor personel" style="margin-left: 15px" >
</select><input name="Search" type="submit" class="my_button round blue" value="CARI">
</form> <br><br>
<?php
$SQL = "SELECT * FROM stock_avail";
if(isset($_POST['Search']) AND trim($_POST['searchtxt'])=="")
{
echo "No Information..";
}
if(isset($_POST['Search']) AND trim($_POST['searchtxt'])!="")
{
$SQL = "SELECT * FROM stock_avail WHERE id = ".$_POST['searchtxt']." ";
}
答案 0 :(得分:0)
搜索表单提交的请求到当前页面位置,现在是patient_first_name_cont = "Ajay"
patient_last_name_cont = "Kumar"
shared_context = Ransack::Context.for(Request)
search_parents = Request.includes(:request_status).ransack(
{ patient_first_name_cont: patient_first_name_cont }, context: shared_context
)
search_children = Request.includes(:request_status).ransack(
{ patient_last_name_cont: patient_last_name_cont }, context: shared_context
)
shared_conditions = [search_parents, search_children].map { |search| Ransack::Visitor.new.accept(search.base)}
@req = Request.joins(shared_context.join_sources).where(shared_conditions.reduce(&:and))
。您需要使用Ajax添加index.php
和/或提交表单和更新页面,如下所示:
action="page_2.php"