mardi 26 juillet 2016

typehead.js JSON AJAX BASIC SETUP

I cant get anything to load or error from typehead.js

This is the script. I check the console and it wont error or get anything I want to load in api data from json format.

$(document).ready(function() {      
        $('input.typeahead').typeahead({        
          source: function (typeahead,query) {
            $.ajax({
              url: '/api/location',
              type: 'POST',
              dataType: 'JSON',
              data: 'sstr=' + query,
              async: true,
              success: function(data) {         
                console.log(data);
                alert("I am an alert box!");

              }
            });
          }
        });
      });

Aucun commentaire:

Enregistrer un commentaire