时间:2021-07-01 10:21:17 帮助过:17人阅读
Ajax做列表无限加载和Ajax做二级下拉选项,供大家参考,具体内容如下
//栏目Ajax做加载 public function ajaxlist(){ //echo "http://www.域名.com/index.php?a=Index&c=Index&m=ajaxlist"; //echo "<hr>"; $data = Q('sum'); $where = array(); $where['cid'] = 33; $rongyuList = M('content')->limit($data,2)->where($where)->select(); $data['stat'] = 1; $data = $rongyuList; $this->ajax($data); //也可以手动把想要的字段拼接成字符串 /*echo "["; foreach($rongyuList as $k){ echo "{"."\""."title"."\"".":"."\"".$k['title']."\"".","."\""."description"."\"".":"."\"".$k['description']."\"".","."\""."cid"."\"".":"."\"".$k['cid']."\""."}".","; } echo "]";*/ }
具体页面实现:
Ajax 做二级选项:
<!-- 示例:HTML --> <dl class="pr keshi" > <dt class="pa">科室:</dt> <dd class="pa"> <select name='keshi' class='m_keshi'> <option value='0'>--请选择科室--</option> </select> <select name='zhuanjia' class='m_zhuanjia'> <option>--请选择专家--</option> </select> </dd> </dl>
示例控制器:
//示例控制器 /* Ajax请求栏目列表 */ public function ajaxlanmu(){ $lanmuList = M('category')->where('pid=142')->select(); $this->ajax($lanmuList); } public function ajaxzhuanjia(){ $where = array(); $data = Q('sum'); $data = $data ? $data : 143; $where['cid'] = $data; $zhuanjiaList = M('guahao')->where($where)->select(); $this->ajax($zhuanjiaList); }
示例:JS
上面是我整理给大家的,希望今后会对大家有帮助。
相关文章:
ajax与跨域jsonp
django 通过ajax完成邮箱用户注册、激活账号的方法
原生ajax的get和post方法使用详解
以上就是Ajax实现列表无限加载和二级下拉选项效果的详细内容,更多请关注Gxl网其它相关文章!