Hi,

I am new to web2py and it is a fantastic framework! The online book is
quite helpful until this week. I tried two AJAX examples but none of
them works and I don't have a clue what went wrong there.

First one is the wiki example:
---------------------------------
def search():
     "an ajax wiki search page"
     return dict(form=FORM(INPUT(_id='keyword',
              _onkeyup="ajax('bg_find', ['keyword'], 'target');")),
              target_div=DIV(_id='target'))

def bg_find():
     "an ajax callback that returns a <ul> of links to wiki pages"
     pattern = '+ request.vars.keyword.lower() + '
     pages = db(db.page.title.lower().like(pattern))\
       .select(orderby=db.page.title)
     items = [A(row.title, _href=URL(r=request, f=show, args=row.id))
\
            for row in pages]
     return UL(*items).xml()
------------------------------------

Nothing shows up when I type or submit my request.

Second one is the auto complete example:
------------------------------------
def month_input():
    return dict()

def month_selector():
    if not request.vars.month:
        return "
    months = ['January', 'February', 'March', 'April', 'May',
            'June', 'July', 'August', 'September' ,'October',
            'November', 'December']
    selected = [m for m in months \
                if m.startswith(request.vars.month.capitalize())]
    return ".join([DIV(k,
                  _onclick="jQuery('#month').val('k')",
                  _onmouseover="this.style.backgroundColor='yellow'",
                  _onmouseout="this.style.backgroundColor='white'"
                  ).xml() for k in selected])
----------------------------------

Again, nothing shows up.... I was using Chrome on linux.... Could
anyone tell me how to get it work please? Many thanks!!!

Cheers,
Zhe

Reply via email to