1. Implementing Ajax in CF7 Basic and Intermediate Level using JavaScript, JSON and ColdFusion 7 Harbinger Systems Pranav Prakash (pranav@HarbingerGroup.com)
12. Creating XMLHttpRequest // create ajaxObject supports all browser with XMLHttpRequest Support ajaxObject = function() { try{ // Firefox, Opera 8.0+, Safari xmlHttp=new XMLHttpRequest(); } catch (e){ // Internet Explorer try{ xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); } catch (e){ try{ xmlHttp=new ActiveXObject("Microsoft.XMLHTTP"); } catch (e){ alert("Your browser does not support AJAX!"); return false; } } } return xmlHttp; } ajax = new ajaxObject(); Harbinger Systems
13.
14.
15.
16.
17.
18.
19. Checking the state of request … if (httpRequest.readyState == 4) { // everything is good, the response is received } else { // still not ready } Harbinger Systems
20.
21. Checking the server response code if (httpRequest.readyState == 4) { if (httpRequest.status == 200) { // perfect! } else { // there was a problem with the request, // maybe a 404 or 500 // show user friendly message } } Harbinger Systems