I'm trying to use tokeninput
from jQuery Token input, but the data is from the API. I already got the data from API and made a JSON list (see below).
When a user inputs in my token input, it will select from the JSON list, like user/auto_unit?queryParam=q
for example. It already gets the user input correctly, but it still returns all data, even those that do not match the user input.
What I want is when the user searches for "Sosiologi", the only values that would show are those string which have "sosiologi" in them.
Is it possible to get only the same values and how can I do that? Thanks in advance!
My JSON list:
// 20170401095401
// http://exp.uin-suka.ac.id/aspirasi/user/auto_unit?queryParam=Filsafat%20Agama
[
{
"id": "UA000001",
"name": "Filsafat Agama"
},
{
"id": "UA000002",
"name": "Perbandingan Agama"
},
{
"id": "UA000003",
"name": "Ilmu Al-Qur'an dan Tafsir"
},
{
"id": "UA000004",
"name": "Sosiologi Agama"
},
{
"id": "UA000005",
"name": "Matematika"
},
{
My JSON code to get the list
function auto_unit() {
$data['unit'] = $this->m_simpeg->getAllUnit();
foreach ($data['unit'] as $key ){
$row['id']= $key['UNIT_ID'];
$row['name']= $key['UNIT_NAMA'];
$row_set[] = $row;
}
echo json_encode($row_set);
}
Model to get API M_simpeg.php:
public function getAllUnit(){
return $this->s00_lib_api->post_api(
1001, 1, null,
URL_API_SIMPEG.'simpeg_mix/data_view'
);
}