Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $(document).ready(function() {
- $( "#search-input" ).autocomplete({
- source: function( request, response ) {
- var base_url = window.location.origin;
- var query = request.term;
- if (query.length > 0) {
- $.ajax({
- url: `${base_url}/search/ajax`,
- dataType: "json",
- data: {
- q: query,
- },
- success: function( data ) {
- console.log(data.length)
- response(data);
- }
- });
- }
- },
- _renderItem: function(ul,item) {
- return $("<li>")
- .append("<div>" + item.title + "</div>")
- .appendTo(ul);
- }
- });
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement