PHP获取JSON生成select下拉选框有关问题
程序员文章站
2022-04-18 19:55:03
...
PHP获取JSON生成select下拉选框问题
这两天搞微信企业号接口,获取了一段JSON,想在PHP里通过userlist中的usrid和name内容生成相关的select下拉选框,应该怎样写好,好似只能用AJAX来搞吧?
------解决思路----------------------
不劳而获是大忌,给你写个示例,结合JQ
这两天搞微信企业号接口,获取了一段JSON,想在PHP里通过userlist中的usrid和name内容生成相关的select下拉选框,应该怎样写好,好似只能用AJAX来搞吧?
"{\"errcode\":0,\"errmsg\":\"ok\",\"userlist\":[{\"userid\":\"ersuo\",\"name\":\"\u6881\u51ef\u6b23\",\"department\":[]},{\"userid\":\"sabrina\",\"name\":\"\u8d75\u5b9d\u83b9\",\"department\":[]},{\"userid\":\"kelly\",\"name\":\"\u9648\u70ab\u534e\",\"department\":[]},{\"userid\":\"eva\",\"name\":\"eva\",\"department\":[]},{\"userid\":\"zhongzhong\",\"name\":\"\u949f\u548f\u6bb7\",\"department\":[]}]}"
------解决思路----------------------
不劳而获是大忌,给你写个示例,结合JQ
var a=JSON.parse("{\"errcode\":0,\"errmsg\":\"ok\",\"userlist\":[{\"userid\":\"ersuo\",\"name\":\"\u6881\u51ef\u6b23\",\"department\":[]},{\"userid\":\"sabrina\",\"name\":\"\u8d75\u5b9d\u83b9\",\"department\":[]},{\"userid\":\"kelly\",\"name\":\"\u9648\u70ab\u534e\",\"department\":[]},{\"userid\":\"eva\",\"name\":\"eva\",\"department\":[]},{\"userid\":\"zhongzhong\",\"name\":\"\u949f\u548f\u6bb7\",\"department\":[]}]}");
var select="";
$("body").append(select)
相关文章
相关视频
下一篇: Laravel 推送通知客户端选择问题