title: jQuery Ajax guess-type/predict issue
body: <p>I am having to use jQuery I did not write, it was included in a template.</p>
  
  <p>There is a function that does a 'guess type,' and uses the main navigation as the data to search against. As you type, pages within the site come up in the dropdown.</p>
  
  <p>I need customer names from a database to dropdown, but I can't seem to get the function to work.</p>
  
  <pre><code>function searchInNav(s)
      {
          // Split keywords
          var keywords = s.toLowerCase().split(/\s+/);
          var nbKeywords = keywords.length;
  
          // Search links
          //var links = $('nav a'); // original
            var links = [];
  
          // LOAD CUSTOMERS AND EVENTS
          $.post('includes/ajax/global.php', { list: 'search', text: keywords },
              function(data){
                  alert(data);
                  links.push($(data));
              },
              "html"
          );
  
          var matches = [];
          links.each(function(i)
          {
              var text = $(this).text().toLowerCase();
              var textMatch = true;
              for (var i = 0; i &lt; nbKeywords; ++i)
              {
                  if (text.indexOf(keywords[i]) == -1)
                  {
                      textMatch = false;
                      break;
                  }
              }
  
              if (textMatch)
              {
                  // All keywords found
                  matches.push(this);
              }
          });
  
          // Build results list
          var nbMatches = matches.length;
          if (nbMatches &gt; 0)
          {
              var output = '&lt;p class="results-count"&gt;&lt;strong&gt;'+nbMatches+'&lt;/strong&gt; match'+((nbMatches &gt; 1) ? 'es' : '')+'&lt;/p&gt;';
              output += '&lt;ul class="small-files-list icon-html"&gt;';
  
              for (var m = 0; m &lt; nbMatches; ++m)
              {
                  // Text with highlighted keywords
                  var link = $(matches[m]);
                  var text = link.text();
                  var path = [text];
                  for (var i = 0; i &lt; nbKeywords; ++i)
                  {
                      text = text.replace(new RegExp('('+keywords[i]+')', 'gi'), '&lt;strong&gt;$1&lt;/strong&gt;');
                  }
  
                  // Path
                  var parent = link;
                  while ((parent = parent.parent().parent().prev('a')) &amp;&amp; parent.length &gt; 0)
                  {
                      path.push(parent.text());
                  }
  
                  output += '&lt;li&gt;&lt;a href="'+matches[m].href+'"&gt;'+text+'&lt;br&gt;&lt;small&gt;'+path.reverse().join(' &gt; ')+'&lt;/small&gt;&lt;/a&gt;&lt;/li&gt;';
              }
  
              return output+'&lt;/ul&gt;';
          }
          else
          {
              return '&lt;p class="results-count"&gt;'+settings.messageNoMatches+'&lt;/p&gt;';
          }
      };
  </code></pre>
  
  <p>I keep getting errors with the links.each line, saying Object has not method each.</p>
  
  <p>What do I need to fix?</p>
  
  <p>Thanks!</p>