Changes between Version 21 and Version 22 of AJAX/Dojo/RefactoredFormSubmit
- Timestamp:
- Feb 20, 2007, 11:12:28 AM (18 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
AJAX/Dojo/RefactoredFormSubmit
v21 v22 84 84 function myinit() { 85 85 // connect the event with the good handler 86 var myButton = dojo.byId("xBtn1") ;87 dojo.event.connect(myButton, "onclick", "sendForm") ;88 } ;86 var myButton = dojo.byId("xBtn1") 87 dojo.event.connect(myButton, "onclick", "sendForm") 88 } 89 89 function sendForm() { 90 90 var fNode = dojo.byId('xForm') 91 91 var fParms = dojo.io.encodeForm(fNode) 92 var myErrorDiv = dojo.byId('errorBox1')93 92 var bindArgs = { 94 93 url: ".", 95 94 mimetype: 'text/plain', 96 95 method: "post", 97 preventCache: true, 96 // useCache: true, 97 // sync: true, 98 98 transport: "XMLHTTPTransport", 99 99 postContent: fParms, … … 107 107 return false 108 108 }, 109 load: function(type, data, http, kwArgs){ 110 // Handle "successful" responses here 109 load: function(type, data, http, kwArgs) 110 { 111 /* 112 * Handle "successful" responses here 113 **/ 111 114 var errStr = '' 115 var errDiv = dojo.byId('errBox1') 112 116 if(type == 'load'){ 113 try 117 try{ 114 118 var json = eval( '(' + data + ')' ) 115 } catch (e){119 }catch (e){ 116 120 // not json 117 document.write(data) 121 // alert(e) 122 if (!http.responseText){ 123 document.write(data) 124 } else { 125 document.write(http.responseText) 126 } 118 127 return false 119 128 } 120 for (x in json) 121 errStr += x + ': ' + json[x] + '<br />' 122 myErrorDiv.innerHTML = errStr 123 } 124 } 125 }; 129 var listElement = document.createElement('ul') 130 errDiv.innerHTML = 'Testing..' 131 if (json.error != null){ 132 errDiv.innerHTML = json.error 133 }else if(json.errors != null){ 134 for (x in json.errors){ 135 myLi = document.createElement('li') 136 myLi.innerHTML = x + ': ' + json.errors[x].toString() 137 listElement.appendChild(myLi) 138 } 139 errDiv.appendChild(listElement) 140 } 141 }} 142 }; 126 143 var xmlhttp = dojo.io.bind(bindArgs) 127 144 return xmlhttp … … 140 157 * Usability issues: HTML 4.01 vs XHTML 1.0 strict vs No javascript 141 158 * XMLHTTPTransport doesnt support file-uploading. 159 * DOM manipulations wont update the raw HTML source, however the correct aspect is preserved. 142 160 143 161 === Notes/Comments/Suggestions === 144 145 Does that make any sense at all?146 162 147 163 Add some comments here. =)