jQuery 自动搜索未在使用 codeigniter 3 的文本框中显示获取的数据
jQuery Autosearch is not showing fetched data on textbox using codeigniter3
我正在使用 Codeigniter3 "autosearch" 功能...我想在 Bootstrap 模态上使用自动搜索获取客户名称...我通过网络获得了输出,但它没有显示在UI...您可以在下面 link "https://ibb.co/D98gwnP"
下载我的输出
我在 jQuery 完整日历中使用的这个 Bootstrap 模态将事件添加到数据库中
Controller.php:
public function get_customer()
{
if(isset($_GET['term']))
{
$result = $this->Calendar_model->search_customer($_GET['term']);
if(count($result)>0)
{
foreach($result as $row)
$arr_result[]=$row;
}
echo json_encode($arr_result);
}
}
Model.php:
public function search_customer($customer)
{
$MainDB = $this->load->database('default', TRUE);
$MainDB->select('Name');
$MainDB->where('IsCustomer','Y');
$MainDB->like('Name', $customer, 'both');
$MainDB->order_by('Name','Asc');
$MainDB->limit(10);
return $MainDB->get('PartyDetail')->result();
}
View.php:
<input type="text" class="form-control" name="customer" id="customer"
placeholder="Customer Name">
jQuery代码:
$('#customer').autocomplete({
source : "<?php echo site_url('Calendar/get_customer');?>"
});
我想使用数据库 table 中的 "Autosearch" 功能将数据填充到文本框中...谢谢先生....
试试这个代码
Controller.php
public function get_customer()
{
if(isset($_GET['term']))
{
$result = $this->Calendar_model->search_customer($_GET['term']);
if(count($result)>0)
{
foreach($result as $row)
$arr_result[]=$row->Name;
echo json_encode($arr_result);
}
}
}
我正在使用 Codeigniter3 "autosearch" 功能...我想在 Bootstrap 模态上使用自动搜索获取客户名称...我通过网络获得了输出,但它没有显示在UI...您可以在下面 link "https://ibb.co/D98gwnP"
下载我的输出我在 jQuery 完整日历中使用的这个 Bootstrap 模态将事件添加到数据库中
Controller.php:
public function get_customer()
{
if(isset($_GET['term']))
{
$result = $this->Calendar_model->search_customer($_GET['term']);
if(count($result)>0)
{
foreach($result as $row)
$arr_result[]=$row;
}
echo json_encode($arr_result);
}
}
Model.php:
public function search_customer($customer)
{
$MainDB = $this->load->database('default', TRUE);
$MainDB->select('Name');
$MainDB->where('IsCustomer','Y');
$MainDB->like('Name', $customer, 'both');
$MainDB->order_by('Name','Asc');
$MainDB->limit(10);
return $MainDB->get('PartyDetail')->result();
}
View.php:
<input type="text" class="form-control" name="customer" id="customer"
placeholder="Customer Name">
jQuery代码:
$('#customer').autocomplete({
source : "<?php echo site_url('Calendar/get_customer');?>"
});
我想使用数据库 table 中的 "Autosearch" 功能将数据填充到文本框中...谢谢先生....
试试这个代码
Controller.php
public function get_customer()
{
if(isset($_GET['term']))
{
$result = $this->Calendar_model->search_customer($_GET['term']);
if(count($result)>0)
{
foreach($result as $row)
$arr_result[]=$row->Name;
echo json_encode($arr_result);
}
}
}