Writing the code inside 'domready' event

Pros * Writing the logic for a specific app is fast and furious * The test environment is the app & Cons * It’s much harder to maintain * A high percentage of code you write for the app isn’t reusable * The test environment is the app

HTML

<form id='myForm' method='post' action='/ajax_html_echo/'>
    <input type='text' name='html' value='Something to respond' />
    <input type='submit' />
</form>
<p id='myContainer'></p>

CSS

#myContainer { 
    margin-top: 10px;
    color: navy; 
    font-weight: bold;
}

JavaScript

dojo.ready(function() {
    dojo.connect(dojo.byId('myForm'), 'onsubmit', function(evt){
        dojo.stopEvent(evt);
        var formNode = evt.target;
        dojo.xhrPost({
            form: formNode,
            url: formNode.action,
            handleAs: "text",
            handle: function(response, ioArgs){ 
                dojo.byId('myContainer').innerHTML = response;
            }
        });
    });
});