| this.status = function(_status) { var s = _status.toString().split(""); switch(s[0]) { case "1": return this.getInformationalStatus(_status); break; case "2": return this.getSuccessfulStatus(_status); break; case "3": return this.getRedirectionStatus(_status); break; case "4": return this.getClientErrorStatus(_status); break; case "5": return this.getServerErrorStatus(_status); break; } } |
| if(ajax.checkReadyState('body', 'loading...', 'loading...', 'loading...') == "OK") { document.getElementById('body').innerHTML = ajax.request.responseText; } |
| { 'header' : 'How to Handle the Ajax Response', 'description' : 'An in-depth explanation of how to handle the Ajax response.', 'sourceUrl' : 'http://www.krishadlock.com/clients/informit/AjaxResponse/AjaxResponse.zip'} |
| if(ajax.checkReadyState('body', 'loading...', 'loading...', 'loading...') == "OK") { eval("var response = ("+ajax.request.responseText+")"); document.getElementById('body').innerHTML = "<b>" + response.header + "</b><br/>" + response.description + "<br/><br/>" + "<a href='" + response.sourceUrl + "'>Download the source files</a>"; } |
| var response = ajax.request.responseXML.documentElement; |
| var header = response.getElementsByTagName('header')[0].firstChild.data; var description = response.getElementsByTagName('description')[0].firstChild.data; var sourceUrl = response.getElementsByTagName('sourceUrl')[0].firstChild.data; |
| document.getElementById('body').innerHTML = "<b>" + header + "</b><br/>" + description + "<br/><br/>" + "<a href='" + sourceUrl + "'>Download the source files</a>"; |