web2py AJAX is not working if the proper URL has not been used

At the moment, I’m playing around with web2py (a nice full-stack bundle to develop Python Web Applications).

I created a simple AJAX button which just shows a simple message:


    <input id="set_mark_newparagraph" type="button" value="{{=T('mark: new paragraph')}}" onclick="ajax('set_mark_newparagraph_onclick','leer','output')" class="btn-large btn-huge">


def set_mark_newparagraph_onclick():
    response.flash=T('marked a new paragraph')
    return T('marked a new paragraph')

I called and clicked the button. Everything is working perfect.
As I’m developing this tool for an Android device, I also called it on my Android Chrome. Of course I’m lazy and just called instead of the whole URL. The page shows up, as the default controller with the index action is invoked automatically.
But it didn’t work. The button just did not do anything. I connected my Android via USB Debugging and found out it tried to call (which, of course, does not work).
So remember, always call the full URL instead of being lazy.

Schreibe einen Kommentar

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert