72 | | ... |
| 74 | function validate() { |
| 75 | var fNode = dojo.byId('xForm'); |
| 76 | var fParms = dojo.io.encodeForm(fNode); |
| 77 | var bindArgs = { |
| 78 | url: ".", |
| 79 | mimetype: 'text/json', |
| 80 | method: "post", |
| 81 | preventCache: true, |
| 82 | transport: "XMLHTTPTransport", |
| 83 | postContent: fParms, |
| 84 | error: function(type, error){ |
| 85 | // handle error here |
| 86 | // var errorBox = dojo.byId('errorMsg'); |
| 87 | // errorBox.childNodes[0].nodeValue = error; |
| 88 | alert(error.message); |
| 89 | return false; |
| 90 | }, |
| 91 | load: function(type, data, evt){ |
| 92 | // handle successful response here |
| 93 | if(type == 'load'){ |
| 94 | var myDiv = dojo.byId('errorBox1') |
| 95 | // XXX not sure what to do if the data is JSON or |
| 96 | // something else.. |
| 97 | var json = dojo.json.evalJson(data) |
| 98 | if(json){ |
| 99 | errStr = '' |
| 100 | for(x in json){ |
| 101 | errStr += x + ': ' + json[x] + '<br />' |
| 102 | } |
| 103 | myDiv.innerHTML = errStr |
| 104 | }else{ |
| 105 | myDiv.innerHTML = "hello, world!" |
| 106 | }} |
| 107 | }} |
| 108 | var xmlhttp = dojo.io.bind(bindArgs) |
| 109 | return xmlhttp |
| 110 | } |