Dojo Tips
From Project Auriga
Here's a collection of tips we're finding for using Dojo. We've actually figured out quite a bit of practice the hard way, and much of this knowledge is not yet documented.
[edit] Use form: instead of content: in xhr requests
Dojo provides a number of XmlHttpRequest methods for submitting content to a server, and these are extremely useful for quickly sending an Ajax request or document to the server. For posts and puts, there are two basic parameters for sending content: content, and form.
The content parameter converts all Dojo widgets into objects that can be passed in the request. The form parameter serializes a form domNode (passed either as a domNode or the id to it) and passes the result just like a regular form. These sound similar, but there are some subtle distinctions:
- Content passes a date as an object, rather than serializing it. If your script is expecting a date in yyyy-MM-dd format, this will cause a problem because instead of that it gets a full ISO string. MySQL cannot parse this string directly, so you need to convert it on the server (at least if you're using PHP).
- Content ignores hidden form elements (unless you make them a dijit.form.TextBox and use CSS to hide them).
- If both Content and Form are present, content overrides form. This allows your function that submits a form to set specific values as a content object, adding to or overriding the value in the form.

