title: web2py Ajax search
body: <p>I'm trying to use an ajax search slice for my website that I found here: <a href="http://www.web2pyslices.com/slices/take_slice/51" rel="nofollow">http://www.web2pyslices.com/slices/take_slice/51</a></p>
  
  <p>But for some reason I keep getting the error:</p>
  
  <pre><code>IndexError: list index out of range
  </code></pre>
  
  <p>Here is my version of the code:</p>
  
  <p><strong>default.py (controller)</strong></p>
  
  <pre><code>def index():
  listings = db().select(db.listing.ALL, orderby=db.listing.first_name)
  
  return dict(listings=listings, livesearch=livesearch())
  
  def livesearch():
      partialstr = request.vars.values()[0]
      query = db.listing.title.like('%'+partialstr+'%')
      listings = db(query).select(db.listing.title)
      items = []
  
      for (i,listing) in enumerate(listings):
          items.append(DIV(A(listing.title, _id="res%s"%i, _href="#", _onclick="copyToBox($('#res%s').html())"%i), _id="resultLiveSearch"))
  
      return TAG[''](*items)
  </code></pre>
  
  <p><strong>livesearch.html (view, which I'm {{including}} in the layout.html</strong></p>
  
  <pre><code>&lt;input type="text" id="search" name="search" autocomplete="off" onkeyup="getData(this.value);" /&gt;&lt;br /&gt;
  &lt;div id="ajaxresults"&gt;&lt;/div&gt;
  </code></pre>
  
  <p><strong>db.py (model)</strong></p>
  
  <pre><code>db.define_table(auth.settings.table_user_name,
              Field('first_name'),
              Field('last_name'),
              Field('email'),
              Field('password','password', length=512, readable=False, label='Password'),
              Field('title'),
              Field('photo','upload'),
              Field('bio','text'),
              Field('phone'), # Contact details
              Field('website'),
              Field('address'),
              Field('registration_key', length=512,
                  writable=False, readable=False, default=''),
              Field('reset_password_key', length=512,
                  writable=False, readable=False, default=''),
              Field('registration_id', length=512,
                  writable=False, readable=False, default=''),
              )
  
  listing = db[auth.settings.table_user_name]
  </code></pre>
  
  <p>Any help would be very very greatly appreciated, cause I've been wracking my brains on it for days now (because I'm extremely new to programming)</p>
  
  <p>Thanks!</p>