openwrt 问题二 js 通过nginx 服务器调用 lua代码的过程实现,openwrtnginx
openwrt 问题二 js 通过nginx 服务器调用 lua代码的过程实现,openwrtnginx
首先 js 代码通过jquery标准函数 实现的http请求
$(document).queue("homequeue", function() { $.getJSON("/test2", function(data) { console.log("data-------------------sucess----------"); isSessionUninvalid(data); $("#content_Home #wifi_name").html(data.id); $(document).dequeue("homequeue"); }).error(function(){ console.log("data-------------------error------------"); $(document).dequeue("homequeue"); }); });
nginx 服务器配置 nginx.conf location /test2 { default_type application/json; content_by_lua_file '/www/monet/test2.lua'; }
test2.lua 程序 local config local ssid local device local uci = require "uci" local cursor = uci.cursor() cursor:foreach("wireless", "wifi-iface", function(s) config = s ssid = s.ssid device = s.device end)
local cjson = require("cjson")
local obj = { id = ssid }
local str = cjson.encode(obj) ngx.say(str)
转载请注明博主地址 http://blog.csdn.net/caofengtao1314
评论暂时关闭