I setup a Ajax call on the pyForum form posts to serialize the form and send it to the macro via Rndr (see separate post about that package if you like). Rndr activates on a url call and renders the pyForumStart macro with a query string that tells the macro to only handle post data. My Python code like this:
requestAjax = library.RequestQueryString("ajax") requestId = library.RequestQueryString("id") if requestAjax: if requestAjax == "getthreads": getlist = ForumThreadsHtml(int(requestId)) print getlist if requestAjax == "post": post = HandleFormPost(None) print post else: print ForumStartView()
A bit slow at first
When I tried out the Ajax-version of the form I was a bit disappointed at first, since each Ajax post took 2 X 0.4 seconds or something. But no surprise actually since every call to the web server do take some tenths of a second. So I changed from two Ajax calls to one. Of course it’s indeed how Ajax should be handled. Dont ever call twice if you can call once.
I remade the code a bit so I have one call – and it makes Ajax posting better.
Have a look at the current demo.
Some nice message and perhaps a fade would make the thing look even better.
Conclusion and progress
Yes, this “Ajax over Rndr + Python” method seem to be fast enough and worth taking a step further. So my next post will be on writing a complete Ajaxified version of pyForum. Including the packaged code. So keep watching this space.