[英]Filter Data based on Multiple Select option with ajax jquery php
I have 3 select option for searching the records in datatable with ajax jQuery php.我有 3 个 select 选项,用于使用 ajax jQuery ZE1BFD762321E409CEE4AC0B 搜索数据表中的记录。
I have write this code but select option data is not going to other page & not returning back from ajax request.我已经编写了此代码,但 select 选项数据不会转到其他页面,也不会从 ajax 请求返回。
PHP Code:- PHP 代码:-
<form name="search_form" id="search_form" method="POST">
<div class="col-md-3">
<div class="formrow">
<select class="form-control" name="job_title" class="select_filter">
<option value ='' disabled selected>Job Title</option>
<option>PHP Developer</option>
<option>Andorid Developer</option>
</select>
</div>
</div>
<div class="col-md-3">
<div class="formrow">
<select class="form-control" name="emptype" class="select_filter">
<option value ='' disabled selected>Employment Status</option>
<option>Permanent</option>
<option>Contract</option>
<option>Freelance</option>
</select>
</div>
</div>
<div class="col-md-3">
<div class="formrow">
<select class="form-control" name="experience" class="select_filter">
<option value ='' disabled selected>Experience</option>
<option>Fresher</option>
<option>1 Year</option>
<option>2 Years</option>
<option>3 Years</option>
<option>4 Years</option>
<option>5 Years</option>
<option>6 Years</option>
<option>7 Years</option>
<option>8 Years</option>
<option>9 Years</option>
<option>10 Years</option>
</select>
</div>
</div>
</form>
jQuery / Ajax Code:- jQuery / Ajax 代码:-
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script type="text/javascript" rel="stylesheet">
$(document).ready(function(){
$('.select_filter').on('change',function(){
$.ajax({
type: "POST",
url: "ajaxCompany_search.php",
data: $('#search_form').serialize(),
success:function(data){
console.log(data);
alert(data);
$("#projects").html(data);
}
});
});
});
</script>
ajaxCompany_search.php ajaxCompany_search.php
<?php
include('../../config.php');
print_r($_POST);
?>
you have to group the class in an uniq tag:您必须将 class 分组到一个 uniq 标签中:
change改变
class="form-control" ... class="select_filter"
to至
class="form-control select_filter"
You have given class two times inside the select field, due to which data is not showing.您已在 select 字段内两次给出 class ,因此未显示数据。
<select class="form-control" name="job_title" class="select_filter">
write code as写代码为
<select class="form-control select_filter" name="job_title">
It is written like this right there那里是这样写的
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.