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 "]";*/ }
Specific page implementation:
Ajax makes secondary options:
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); }
Example: JS
The above is what I compiled for everyone. I hope it will be helpful to everyone in the future.
Related articles:
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!