Javascript 使用Get方法使用codeigniter获取数据
我有代码,可以从数据库中搜索信息,而无需刷新页面(如搜索输入),并且可以正常工作Javascript 使用Get方法使用codeigniter获取数据,javascript,php,codeigniter,Javascript,Php,Codeigniter,我有代码,可以从数据库中搜索信息,而无需刷新页面(如搜索输入),并且可以正常工作 // check.php <?php include "db.php"; $show = $_GET['nm']; $res = mysql_query("SELECT * FROM post_job WHERE job_title like('$show%')"); echo"<table>"; while($ress = mysql_fetch_array($res))
// check.php
<?php
include "db.php";
$show = $_GET['nm'];
$res = mysql_query("SELECT * FROM post_job WHERE job_title like('$show%')");
echo"<table>";
while($ress = mysql_fetch_array($res))
{
echo '<tr>';
echo '<td>'.$ress['first_name'].' '.$ress['last_name'].'</td>';
echo '<td>'.$ress['gender'].'</td>';
echo '<td>'.$ress['phone'].'</td>';
echo '</tr>';
}
echo"</table>";
?>
对于视图路径,我使用相同的输入表单,但我更改了这个xmlhttp.open(“GET”,“/inquiry/search?check=“+document.form1.t1.value,false)代码>用于Java脚本。
问题:如果我键入任何值进行搜索,告诉我找不到404页。
我尝试将我的config.php更改为$config['uri_protocol']='PATH_INFO'代码>但不工作。。。
请我需要解决方案复制url并在浏览器中运行,看看您得到了什么输出。不使用codeigniter我得到了很好的结果,使用它我得到了404页未找到。但我只是发现了一些有用的东西,却没有显示出结果。。。。我将javascript函数更改为:xmlhttp.open(“GET”,“?check=“+document.form1.t1.value,false)代码>
<form action="" name="form1" method="POST" >
<label>Search</label><input type="text" name="t1" onKeyUp="aa();">
<div id="d1"></div>
</form>
<script type="text/javascript">
function aa()
{
xmlhttp = new XMLHttpRequest();
xmlhttp.open("GET","check.php?nm="+document.form1.t1.value, false);
xmlhttp.send(null);
// this id useful for storing response
document.getElementById("d1").innerHTML = xmlhttp.responseText;
}
</script>
//Controller
public function search()
{
$data = array();
$keyword = $this->input->get('check');
$jobs = $this->profile_model->comSeasrch($keyword);
$data['show'] = $jobs;
}