前端之家收集整理的这篇文章主要介绍了
一个简单的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);}
原文链接:https://www.f2er.com/ajax/166238.html