Home  >  Article  >  Web Front-end  >  Ajax realizes infinite loading of lists and secondary drop-down option effects

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

亚连
亚连Original
2018-05-22 10:57:511272browse

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:

ajaxwith cross-domain jsonp

django via ajax Methods 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!

Statement:
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