lua - jquery dataTables plug in - how to get querystring values on server side? -
i have following querystring being created datatable:
http://testserver/cgi-bin/widget?draw=1&columns%5b0%5d%5bdata%5d=0&columns%5b0%5d%5bname%5d=&columns%5b0%5d%5bsearchable%5d=true&columns%5b0%5d%5borderable%5d=true&columns%5b0%5d%5bsearch%5d%5bvalue%5d=&columns%5b0%5d%5bsearch%5d%5bregex%5d=false&columns%5b1%5d%5bdata%5d=1&columns%5b1%5d%5bname%5d=&columns%5b1%5d%5bsearchable%5d=true&columns%5b1%5d%5borderable%5d=true&columns%5b1%5d%5bsearch%5d%5bvalue%5d=&columns%5b1%5d%5bsearch%5d%5bregex%5d=false&columns%5b2%5d%5bdata%5d=2&columns%5b2%5d%5bname%5d=&columns%5b2%5d%5bsearchable%5d=true&columns%5b2%5d%5borderable%5d=true&columns%5b2%5d%5bsearch%5d%5bvalue%5d=&columns%5b2%5d%5bsearch%5d%5bregex%5d=false&columns%5b3%5d%5bdata%5d=3&columns%5b3%5d%5bname%5d=&columns%5b3%5d%5bsearchable%5d=true&columns%5b3%5d%5borderable%5d=true&columns%5b3%5d%5bsearch%5d%5bvalue%5d=&columns%5b3%5d%5bsearch%5d%5bregex%5d=false&order%5b0%5d%5bcolumn%5d=1&order%5b0%5d%5bdir%5d=asc&start=0&length=10&search%5bvalue%5d=&search%5bregex%5d=false&_=1431373301322
from cgi script, can extract values "draw" , "start" doing
local start = form.start local draw = form.draw
but need know how @ other values. in f12 tool in ffox, can see have values columns[1][data]:1 can't seem right syntax @ these values. in query string i've shown above, value sent/ posted "columns%5b1%5d%5bdata%5d=1"
i've tried following combinations:
--log(form.columns.1.data) --log(form.columns[1][data]) --log(form.columns[1]['data']) --log(form.columns['1']['data'])
i've run tests on lua command line make sure know how access values stored in multidimensional arrays
lua 5.1.5 copyright (c) 1994-2012 lua.org, puc-rio > mt = {} > mt[1]={} > mt[1]['data']=1 > print(mt[1].data) 1 > print(mt[1]['data']) 1 >
any suggestions appreciated. thanks.
the querystring percent encoded since querystrings can't have e.g. brackets in them. have decode before using it. here example of how (toward end of page). 2 methods:
function unescape (s) s = string.gsub(s, "+", " ") s = string.gsub(s, "%%(%x%x)", function (h) return string.char(tonumber(h, 16)) end) return s end
which used by
cgi = {} function decode (s) name, value in string.gfind(s, "([^&=]+)=([^&=]+)") name = unescape(name) value = unescape(value) cgi[name] = value end end
Comments
Post a Comment