Why don't I see any value from autocomplete search in jQuery
Is $config['compress_output'] = TRUE;
in your application/config/config.php
?
If it is, you can't output content directly from the controller methods. You must use a view. You can create a view as simple as:
<?php echo $response;
and just pass the json data like this:
function search() { $searchterm = $this->input->post('search_hotel'); $data['response'] = json_encode($this->d_book_groups->sw_search($searchterm)); $this->load->view('ajax/json_response', $data);}
I dont know why, but you make a mistake in this code:
$.each(data.name, function (a, b) { $("#suggestion_tab").append('<li>' + data.b + '</li>');});
You can not use "data.b" in $.each method, b is an object of data.namefor more help, actually "b" equal to data.name[a](data.name[a] == b)
So data.b is false, (data.name[a] == b) && data.name[a] != data.b
Use console.log(b) in $.each loop to see your array object (you need firefox and firebug extention)
$.each(data.name, function (a, b) { console.log(b);});
I think you want to put each name, in li element, if its true, use this code:
$.each(data, function (a, b) { $("#suggestion_tab").append('<li>' + b.name + '</li>');});
// here b.name == data[a].name