Dojo Dijit and HTML5 in Real world applications/Dojo/dojo.xhrPost: Difference between revisions

From PMISwiki
Jump to navigation Jump to search
(Created page with "__NOTOC__ =={{SUBPAGENAME}}== ==How to use== ==Example implemenataion== Synntax highlight based on html5: <syntaxhighlight lang="html5"> </syntaxhighlight> <syntaxhighlight la...")
(No difference)

Revision as of 16:47, 27 April 2012

dojo.xhrPost

How to use

Example implemenataion

Synntax highlight based on html5:

<script type="text/javascript">
function xSendForm() {
  
        var defaultxhrArgs = {
            form: dojo.byId('dialog_loginformA'),
            url: 'http://atajo.biz/test_versions/week15/dss/login.php?JSON=JSON',
            handleAs: 'json',
            load: function(responseObject, ioArgs){
                    
                    var textBuffer = responseObject.message + '<br>Status: ' +responseObject.status;
                    dojo.byId('dialog_loginerror_pane').innerHTML = textBuffer;
                    
                    if (responseObject.status == 'OK') {
                        setTimeout(function hideDialog(){
                            
                            dojo.byId ('dialog_loginerror_pane').innerHTML = '';
                            dijit.byId('dialog_loginpassword').reset();
                            dijit.byId('dialog_login').hide();
                            return true;
                        }, 1300);
                    } else {
                        dijit.byId('dialog_loginpassword').reset();
                        dijit.byId('dialog_loginpassword').focus();
                    }                           
           },
            error: function(error, ioargs) {
                    var message = '';
                    switch (ioargs.xhr.status) {
                    case 404:
                        message = 'Siden blev ikke fundet!';
                        break;
                    case 500:
                        message = 'Serveren rapporterede en fejl!.';
                        break;
                    case 403:
                        message = 'Din session er timet ud. Log ind igen!';
                        break;
                    default:
                        message = 'Ukendt fejl!.';
                    }         
                    dojo.byId('dialog_loginerror_pane').innerHTML = message;
                    return true;
            }
        }
        //Call the asynchronous xhrPost
        dojo.byId('dialog_loginerror_pane').innerHTML = 'Anmodning sendes...';
        var deferred = dojo.xhrPost(defaultxhrArgs);
}

</script>

Verified in

IE 8, Firefox 3.6.22, Dojo 1.6.1

References

Document History

Version Date Author Status Purpose of update
1 14 Apr 2012 PSA Draft Not released.