Note that there are some explanatory texts on larger screens.

plurals
  1. POWhats wrong with my JS / jQuery code?
    primarykey
    data
    text
    <p>I'm trying to build an autocomplete jQuery input. I have a form that contains an input, and I want the autocomplete to work with Yelp's API to autocomplete restaurant names. when I run the page and type anything into the input textbox, nothing happens</p> <p>here is my code:</p> <pre><code>&lt;html&gt; &lt;body&gt; &lt;input id="restaurantSearch" /&gt; &lt;pre&gt; &lt;script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js"&gt;&lt;/script&gt; &lt;script type="text/javascript" src="http://oauth.googlecode.com/svn/code/javascript/oauth.js"&gt;&lt;/script&gt; &lt;script type="text/javascript" src="http://oauth.googlecode.com/svn/code/javascript/sha1.js"&gt;&lt;/script&gt; &lt;script type="text/javascript" src="https://github.com/jamespadolsey/prettyPrint.js/raw/master/prettyprint.js"&gt;&lt;/script&gt; &lt;script&gt; $(document.ready(function() { $('#restaurantSearch').autocomplete({ alert(req); source: function(req, add){ var auth = { // // Update with your auth tokens // consumerKey: "xxx", consumerSecret: "xxx", accessToken: "xxx-xxx", accessTokenSecret: "xxx", serviceProvider: { signatureMethod: "HMAC-SHA1" } }; var terms = req; var near = 'San+Francisco'; var accessor = { consumerSecret: auth.consumerSecret, tokenSecret: auth.accessTokenSecret }; parameters = []; parameters.push(['term', terms]); parameters.push(['location', near]); parameters.push(['callback', 'cb']); parameters.push(['oauth_consumer_key', auth.consumerKey]); parameters.push(['oauth_consumer_secret', auth.consumerSecret]); parameters.push(['oauth_token', auth.accessToken]); parameters.push(['oauth_signature_method', 'HMAC-SHA1']); var message = { 'action': 'http://api.yelp.com/v2/search', 'method': 'GET', 'parameters': parameters }; OAuth.setTimestampAndNonce(message); OAuth.SignatureMethod.sign(message, accessor); var parameterMap = OAuth.getParameterMap(message.parameters); console.log(parameterMap); $.ajax({ 'url': message.action, 'data': parameterMap, 'dataType': 'jsonp', 'jsonpCallback': 'cb', 'success': function(data, textStats, XMLHttpRequest) { console.log(data); var output = prettyPrint(data); $("body").append(output); } }); }); &lt;/script&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>'</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload