This ajax call is doing the server side stuff but failing to update
the client.  I am about at wit's end with this.

This is the client side call to ajax:

 ajax('{{=URL('add_training')}}',
                ['user_training_id', 'user_training_source'],
                ':eval')

This is the server side function:
def remove_training():
    id_list = str(request.vars.user_training_id).split('_')
    user_id = id_list[0]
    course_id = id_list[1]
    db((db.training_requirements.user_id == user_id) &
            (db.training_requirements.course_id ==
course_id)).delete()
    mystring = training_plan_status(user_id)
    return "jQuery('#training_plan_status').html('" + mystring + "');"

I think the problem lies in this snippet from training_plan_status().
It seems to stick something in the output string that :eval does not
like.  If I replace "return out" with "return 'found some rows,' the
browser updates the target.  Also if it falls through to the "else" at
the end, the browser updates the target.

    if len(okay) > 0:
        out = '<h3>Qualified</h3>' + str(TABLE(
                THEAD(TR(TH('Course
name'),TH('Status'),TH('Action'))),
                *[TR(*rows) for rows in okay]))
    if len(not_okay) > 0:
        if len(out) > 0:
            out += '<hr>'
        out += '<h3>Not qualified</h3>' + str(TABLE(
                THEAD(TR(TH('Course
name'),TH('Reason'),TH('Action'))),
                *[TR(*rows) for rows in not_okay]))
    if len(out) > 0:
        return out
    else:
        return 'No training plan defined'

training_plan_status() works on initial page load when called by the
edit function.  It also works if I replace :eval in the client side
ajax call with the id of the target and sent its output without the
jQuery wrapper.

Anybody got any ideas?

Reply via email to