javascript - jQuery UI autocomplete drop down not displaying -


i trying use jquery ui autocomplete feature search spotify's music library. while passes well, , successful response:

jquery autocomplete spotify song search

there no drop down suggestions. instance searching "time" , wanted see:

  • time hans zimmer <--(this searching for)
  • back in time pitbull
  • elevate big time rush

etc. here javascript code:

<script>$(function() {$( "#spotify_song_search" ).autocomplete({source: function(request, response) {         $.get("http://ws.spotify.com/search/1/track.json", { q: request.term },function( data ) { alert(data); response(data);});     },success: function(data) {             // pass data response callback              alert(data); response(data);         }});});</script>  

i must doing wrong. checked jquery docs here: http://jqueryui.com/demos/autocomplete/ doesn't give explanation why occur. , added alerts see if @ least response, do, returns [object object]. need display search results?

error: uncaught syntaxerror: unexpected token illegal on line 417: enter image description here

the autocomplete widget expects data formatted in specific way can parsed. array supply or pass response callback must be:

  1. an array strings, or
  2. an array objects have label property, value property, or both.

(see autocomplete's documentation under "overview" / "expected data format" more information)

the typical way when have data source can't change use $.map transform results format autocomplete expects:

$("#spotify_song_search").autocomplete({     source: function(request, response) {         $.get("http://ws.spotify.com/search/1/track.json", {             q: request.term         }, function(data) {             response($.map(data.tracks, function (el) {                 return el.name;             }));         });     } }); 

example: http://jsfiddle.net/anmus/ (note: not appear working in firefox right now; may due size of response. works fine in chrome though)


Comments

Popular posts from this blog

django - How can I change user group without delete record -

java - Need to add SOAP security token -

java - EclipseLink JPA Object is not a known entity type -