On Oct 24, 1:56 am, cjrh <[email protected]> wrote:
> Would I have to use javascript?
>
> My tests below doesn't seem to permanently update the session object
> inside setnum(), even though request.args does contain the number sent
> by ajax. Inside showme(), the session value is default once again,
> making me thing the cookies are somehow required in the ajax call.
Ok, I was wrong. Everything does work as expected, provided you do
the following:
A(
'Click Me',
_href=URL(f='showme'),
_onclick=XML("$.ajax({url: 'setnum/" + str(i) + "', async:
false})")
)
The trick there is the "async: false". My problem was a race between
the ajax session update (inside controller function setnum) versus the
page display of session status in controller function showme().
It all now works as expected, however, I remain unsure about this as a
viable strategy anyway. I would love to hear about best practice here.