Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Lots of people have explained the mechanics of clearing, which it sounds like you already understand, so perhaps the missing piece is <strong>when</strong> to do it. You probably want to clear things as the very first thing in your Freebase Suggest select callback, before you fire off any of the queries to other services like Spotify (i.e. before the first $.getJSON()).</p> <p>Not related to your question, but don't forget the attribution requirement of the Freebase license (not currently provided on your web site).</p> <p>EDIT: Here's your code with empty added:</p> <pre><code>$('#myinput').suggest({key: "&lt;mykey&gt;","filter": "(all type:/music/musical_group )" }) .bind("fb-select", function(e, data) { $('#spotify-div').empty(); // empty the div before fetching and adding new data $.getJSON("http://ws.spotify.com/search/1/track.json?q="+search_val, function(data) { items = []; $.each(data["tracks"], function(key, val) { items.push('&lt;li class="spot"&gt;&lt;span typeof="MusicRecording" property="track"&gt;&lt;p&gt;Name: &lt;strong&gt;&lt;span property="name"&gt;' + val["name"] + '&lt;/span&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt; &lt;p&gt;Album &lt;strong&gt;' + val.album["name"] + '&lt;/strong&gt;&lt;/p&gt;&lt;p&gt; Released: &lt;strong&gt;' + val.album["released"] +'&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;&lt;a href="' + val["href"] +'"&gt;&lt;i class="icon-play-sign"&gt;&lt;/i&gt; Start Spotify&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;'); if ( key === 7 ) { return false; } }); $('#spotify-div').prepend('&lt;h3 style="border-bottom:1px solid white;"&gt;Spotify tracks&lt;/h3&gt;'); $('#spotify').html(items.join('&lt;/li&gt;')); }); }); </code></pre>
 

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