一个简单的AJAX多调用

创建AJAX对象函数 function getXmlHttp() {try {return new XMLHttpRequest();} catch(e) {try {return new ActiveXObject("Msxml2.XMLHTTP");} catch(e) {try {return new ActiveXObject("Msxml3.XMLHTTP");} catch(e) {try {return new ActiveXObject("Microsoft.XMLHTTP");} catch(e) {return null;}}}}}var xmlHttp = getXmlHttp();function mychange() {if(xmlHttp.readyState == 4 && xmlHttp.status == 200) {ajaxResult = xmlHttp.responseText;}}

实例:
function ajaxMajor(id,val){ var url = "source/selectmajors.php?collegeid=" + val;xmlHttp.open("post",url,false);xmlHttp.onreadystatechange = mychange;xmlHttp.send(null);}

你可能感兴趣的:(一个简单的AJAX多调用)