Send entry data from the text field through AJAX, live search
-
Hello!
Can you tell me how to adapt the live search flame to ajax request/response?
http://jqueryui.com/autocomplete/#categories
In other words, how do we send the data to the server?
After the interview, I'm planning on getting these data in the .php file, processing, making a sample of the bud and forming a line of view:
{ label: "annhhx10", category: "Products" },
Then insert
var data = []
Or maybe we should do something different?
Please help me with the frontend to send data for this flame! Thank you!
-
http://jquery.page2page.ru/index.php5/%D0%90%D0%B2%D1%82%D0%BE%D0%B7%D0%B0%D0%BF%D0%BE%D0%BB%D0%BD%D0%B5%D0%BD%D0%B8%D0%B5 a little more examples in Russian. And as many examples as I can tell, it's almost your case. Good luck. This is an example of the URL change code:
$( "#tags" ).autocomplete({ source: function(request, response){ // организуем кроссдоменный запрос $.ajax({ url: "http://ws.geonames.org/searchJSON", dataType: "jsonp", // параметры запроса, передаваемые на сервер (последний - подстрока для поиска): data:{ featureClass: "P", style: "full", maxRows: 12, name_startsWith: request.term }, // обработка успешного выполнения запроса success: function(data){ // приведем полученные данные к необходимому формату и передадим в предоставленную функцию response response($.map(data.geonames, function(item){ return{ label: item.name + (item.adminName1 ? ", " + item.adminName1 : "") + ", " + item.countryName, value: item.name } })); } }); }, minLength: 2 });