In this lecture, we did more examples of Ajax. In particular, we did:
- index_comments: an example of how to add comments to a blog post via Ajax.
- index_rating: an example of how to use JQuery UI to do rating of blog posts, submitting the rating via Ajax.
This is the app we developed in class, after my debugging. Notes:
- Note that the method serializeArray to serialize a form as an array always sends strings, not integers, even for fields of type integer.
- I have added logging.
- The easiest way to debug this type of code is if you run it with the appengine simulator, since the logs are then very comprehensive and easy to read. Otherwise, for Ajax, you have sometimes to read the HTML in the errors/ directory, which is not pleasant. Point your browser to that directory for an easier experience.
Here are pointers to two very important resources for writing Javascript and Ajax:
- JQuery
- JQuery UI, containing lots of useful effects, such as the rating thing we are using, but also collapsible elements, progress bars, sortable lists, accordions, and much more.