Thursday, 5 September 2013

Boostrap typehead, load Ajax with segment instead of query string?

Boostrap typehead, load Ajax with segment instead of query string?

How can I use typehead to search with query directly in the url instead of
using query strings?
$("input:text[name='marca']")
.typeahead({
source: function (query, process) {
jQuery.ajax({
url: "/marcas/search/" + query,
type: 'GET',
data: {q: query},
dataType: 'json',
success: function (json) {
process([json.suggestion]);
}
});
}
});
With JQuery autocomplete I used to do:
$("input:text[name='marca']")
.autocomplete({
source: function(request, response) {
$.getJSON("/marcas/search/" + request.term, { },
function(src){
response(src);
});
},
autoFocus: true
})

No comments:

Post a Comment