php+ajax实现select分类二级菜单效果
程序员文章站
2022-05-04 20:30:29
...
html代码如下:
ajax代码如下:
// 创建ajax引擎 function getXmlHttpObject() { var xmlHttpRequest; if (window.ActiveXObject) { xmlHttpRequest = new ActiveXObject("Microsoft.XMLHTTP"); } else { xmlHttpRequest = new XMLHttpRequest(); } return xmlHttpRequest; } var myXmlHttpRequest = ""; function getArea() { //alert(ID('teId').value); myXmlHttpRequest = getXmlHttpObject(); // 怎样判断是否可以www.111cn.net if (myXmlHttpRequest) { // post 发送数据 var url = "ajax_tiwen.php"; var date = "teId=" + ID('teId').value; myXmlHttpRequest.open("post", url, true); myXmlHttpRequest.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=utf-8"); myXmlHttpRequest.onreadystatechange = TiWen; myXmlHttpRequest.send(date); } }
php代码如下:
'; $str.= ' '; $str.= ''; echo $str; exit; } else { $str.= ''; echo $str; } ?>
永久地址:
转载随意~请带上教程地址吧^^