PHP从数据库取出数据:$datas = common::getDatas( "id,crtId,crtTime" , "audio" , [ "str" => "crtId=?" , "bind" => [ 1 ] ] );PHP渲染:现在不想用后端渲染,想用PHP直接把数据json化发送到前端,直接由JS渲染:$response["code"] = "1";$response["mes"] = "ok";$response["data"] = $datas;发到前端的数据是这样的:{"code":"1","mes":"ok","data":[{"id":"989","crtId":"1","crtTime":"2017-01-06 15:54:14"},
{"id":"988","crtId":"1","crtTime":"2017-01-06 11:19:36"},{"id":"987","crtId":"1","crtTime":"2017-01-06 11:10:13"}]}本菜鸟对JS不熟悉,只会一点基础的语法。想知道js怎么才能像PHP那样foreach,然后将需要的字段填充的HTML里面,而不是拼接HTML代码。前端有没有像PHP那样傻瓜式填充的技术?JS真的好难。
添加回答
举报
0/150
提交
取消