1.控制器返回数据集

echo json_encode($res);die;

[{"id":805,"pid":803,"title":"\u5e7f\u5dde-\u7535\u8bdd\u987e\u95ee1"},{"id":804,"pid":803,"title":"\u5e7f\u5dde-\u7535\u8bdd\u987e\u95ee2"},

2.JS读取

				var data1 ;
						$.ajax({
								url:'{:url('register')}',
								type:"post",
								data:{action:'js_type',tid:{$tid},cid:{$cid},ccid:{$ccid}},
								async:false,
								success:function(data){
								  data1 = JSON.parse(data);
								  //console.log(data1);
								},
								error:function(){
								  layer.msg('读取数据失败!');
								}
						});
						
						//console.log(data1);
				//var data=[{"id":1,"pid":0,"title":"1-1"},{"id":2,"pid":0,"title":"1-2"},{"id":3,"pid":0,"title":"1-3"},{"id":4,"pid":1,"title":"1-1-1"},{"id":5,"pid":1,"title":"1-1-2"},{"id":6,"pid":2,"title":"1-2-1"},{"id":7,"pid":2,"title":"1-2-3"},{"id":8,"pid":3,"title":"1-3-1"},{"id":9,"pid":3,"title":"1-3-2"},{"id":10,"pid":4,"title":"1-1-1-1"},{"id":11,"pid":4,"title":"1-1-1-2"}];
				
				interact.render({
					elem : '.test',
					title : '选择联动',
					data : data1,
					name : 'region',
				});

 

GitHub 加速计划 / js / json
41.72 K
6.61 K
下载
适用于现代 C++ 的 JSON。
最近提交(Master分支:1 个月前 )
960b763e 4 个月前
8c391e04 6 个月前
Logo

旨在为数千万中国开发者提供一个无缝且高效的云端环境,以支持学习、使用和贡献开源项目。

更多推荐