[eluser]SaSa[/eluser]
i want display result search live(online) and search letters to letters (transliteration). echo(print) result search(of database) with jQuery( to success: function(data) )
Quote:For example, the I mean apparent:
i have to database this words : salam, salavat, sabos, sandal, sefid, siah and ...
i type to search box : s --display this words--> salam, salavat, sabos, sandal, sefid, siah
now if type : sa --display this words--> salam, salavat, sabos, sandal,
if type : sala --display this words--> salam, salavat
if type : salam --display this words--> salam
why not show search results(success: function (data)) in ajax call? i use of CodeIgniter. It does no error and no results
js:
Code:
$('#hotel').keypress(function () {
var dataObj = $(this).closest('form').serializeArray();
$.ajax({
url: 'http://localhost/mehdi/admin/tour/search_hotel',
data: dataObj,
dataType: 'json',
success: function (data) {
$("#suggestion_tab").html('');
$.each(data.name, function (a, b) {
$("#suggestion_tab").append('<li>' + data.b + '</li>');
});
// Display the results
///alert(data);
},
"error": function (x, y, z) {
// callback to run if an error occurs
alert("An error has occured:\n" + x + "\n" + y + "\n" + z);
}
});
});
CI_Controller
Code:
function search_hotel(){
$searchterm = $this->input->post('search_hotel');
echo json_encode($this->model_tour->search_hotel($searchterm));
}
CI_Model
Code:
function search_hotel($searchterm)
{
$query = $this->db->order_by("id", "desc")->like('name', $searchterm)->get('hotel_submits');
$data = array();
foreach ($query->result() as $row)
{
$data[] = $row->name;
}
return $data;
//return mysql_query("select * from hotel_submits where name LIKE '".$searchterm."'");
}
I hope you understand my mean. what is your comment?
With respect