Ajax realizes infinite loading of lists and secondary drop-down option effects

亚连
Release: 2018-05-22 10:57:51
Original
1334 people have browsed it

This article mainly introduces Ajax to achieve infinite loading of lists and the effect of secondary drop-down options in detail. It has certain reference value. Interested friends can refer to

Ajax to achieve unlimited loading of lists. Make secondary drop-down options with Ajax for your reference. The specific content is as follows

//栏目Ajax做加载 public function ajaxlist(){ //echo "http://www.域名.com/index.php?a=Index&c=Index&m=ajaxlist"; //echo "
"; $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 "]";*/ }
Copy after login

Specific page implementation:

Copy after login

Ajax makes secondary options:

 
科室:
Copy after login

Example controller:

//示例控制器 /* 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); }
Copy after login

Example: JS

Copy after login

The above is what I compiled for everyone. I hope it will be helpful to everyone in the future.

Related articles:

ajaxwith cross-domain jsonp

django viaajaxMethods for completing email user registration and activating accounts

Detailed explanation of the use of get and post methods of nativeajax

The above is the detailed content of Ajax realizes infinite loading of lists and secondary drop-down option effects. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!