Ajax应用
2011年08月01日
一. 正规的Ajax
var xmlHttp; var xmlHttp; function createXMLHttp(){ if(window.ActiveXObject){ xmlHttp = new ActiveXObject("Microsoft.XMLHTTP"); } else if(window.XMLHttpRequest){ xmlHttp = new XMLHttpRequest(); } } function callBack(){ if (xmlhttp.readyState == 4 && xmlhttp.status == 200){ var text = xmlhttp.responseText; //do... } } function callHandler(){ createXMLHttp(); xmlhttp.onreadystatechange = callBack; var url = ""; xmlHttp.open("get",url,true); xmlHttp.send(); }
二. Prototype.js下的Ajax
function callHandler(){ var url = ''; var pars = ''; var myAjax = new Ajax.Request( url, {method: 'get', parameters: pars, onComplete:callBack}); } function callBack(originalRequest){ var text=originalRequest.responseText; }
2011年08月01日
一. 正规的Ajax
var xmlHttp; var xmlHttp; function createXMLHttp(){ if(window.ActiveXObject){ xmlHttp = new ActiveXObject("Microsoft.XMLHTTP"); } else if(window.XMLHttpRequest){ xmlHttp = new XMLHttpRequest(); } } function callBack(){ if (xmlhttp.readyState == 4 && xmlhttp.status == 200){ var text = xmlhttp.responseText; //do... } } function callHandler(){ createXMLHttp(); xmlhttp.onreadystatechange = callBack; var url = ""; xmlHttp.open("get",url,true); xmlHttp.send(); }
二. Prototype.js下的Ajax
function callHandler(){ var url = ''; var pars = ''; var myAjax = new Ajax.Request( url, {method: 'get', parameters: pars, onComplete:callBack}); } function callBack(originalRequest){ var text=originalRequest.responseText; }