The view is not processed on an ajax request. If I am sending ajax requests to a controller that also serves a page, then I like to send a variable with the ajax request to let me know:
def index(): if request.vars.is_ajax: return DIV('this is an ajax request') ...do normal processing here... There may be a better way though. On Nov 19, 10:16 pm, Wes James <compte...@gmail.com> wrote: > This last week I've been trying to use ajax on pages so that > everything is fromhttp://host/app. > > It seems that full mvc works when you > usehttp://host/app/controller/default/view, but if you > havehttp://host/app/and then use: > > ajax('/app/controller/view',[],'register-data') that only the > controller information is return. What I would like is when ajax() is > call that the data from the view is returned, i.e. the html from the > view. > > for instance say I have: > > def profile(): > student=db(db.student.sid==user_id).select() > if (student): > form=crud.update(db.student,student[0],next=URL(r=request)) > else: > form=crud.create(db.student,next=URL(r=request)) > if form.errors: > response.flash="There was an error submitting the form! > Please check for any errors below the fields." > return dict(form=form,response=response) > > if I go tohttp://host/app/default/profile (meaning there is "def > profile" in default.py and profile.html in default/profile.html) this > will work fine. > > But if I load the pagehttp://host/appthen use > ajax('/app/default/profile', [], 'adiv') then the div is filled with > python object, where as if def profile (): return "html" will return > proper info to adiv. Why is this? It seems like the view is skipped > with ajax() js. > > thx, > > -wes --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "web2py-users" group. To post to this group, send email to web2py@googlegroups.com To unsubscribe from this group, send email to web2py+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/web2py?hl=en -~----------~----~----~----~------~----~------~--~---