Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <script>
- $(function() {
- var queries = [];
- $("#searchBox").autocomplete({
- source: function(request, response) {
- var resp = [{
- label:"חיפוש חופשי: " + term,
- value: term,
- url: location.protocol + '//' + location.host + "/?s=" + request.term
- }];
- var q = $.ajax({
- url: "http://hebrew-academy.org.il/wp-admin/admin-ajax.php",
- dataType: "json",
- data: {
- action: 'autocompleteCallback',
- term: request.term
- },
- success: function(data) {
- console.log(typeof(data));
- var d = $.map(data.results, function(item){
- var title = $("<div />").html(item.title).text();
- return {
- label: title,
- url: item.url
- }
- });
- Array.prototype.push.apply(resp, d);
- },
- error: function(jqXHR, textStatus, errorThrown) {
- console.log(jqXHR, textStatus, errorThrown);
- }
- });
- q.then(function(){
- queries.shift();
- response(resp);
- });
- response(resp);
- }
- })
- });
- </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement