多语言展示
当前在线:920今日阅读:2今日分享:31

使用Ajax实现级联菜单

通过ajax、php、 mysql实现级联菜单
工具/原料
1

mysql

2

thinkphp

3

jq

方法/步骤
1

首先创建地区数据表,表字段包括id、name、reid数据表网盘地址(链接:https://pan.baidu.com/s/1fMgF9l16O8ySd5M4ElL-XA 密码:erdu)

3

后台返回身份数据$province = M('area')->where('reid=0')->select();$this->assign('province',$province);$this->display();

4

js代码 请求城市

5

后台处理返回城市数据            $parent_id['reid'] = I('post.reid','','trim');            $region = M('area')->where($parent_id)->select();            $opt = '';            foreach($region as $key=>$val){                $opt .= '';             }             echo json_encode($opt);

6

页面实现结果如图所示

推荐信息