OpenWrt Forum Archive

Topic: Problem in xhr.poll of LuCI { SOLVED }

The content of this topic has been archived on 29 Apr 2018. There are no obvious gaps in this topic, but there may still be some posts missing at the end.

I want to pass some arg from a htm file to a function which locates in */controller/   like:

entry({"admin", "network", "mine"}, call("my_function"), nil).leaf = true

my_function(arg)
  --[[
    *****
]]--
end

The code in htm file is like:

arg = prompt("Input you number: ")
XHR.poll('<% luci.dispather.build_url("admin", "network", "mine") %>', arg, callback);

but the arg is never passed to the function. I saw a similar example in wifi_status.htm. But the arg is a lua data. Like:

 XHR.poll('<% luci.dispather.build_url("admin", "network", "wireless_status", self.ifname) %>' ,null, callback);

So here is the problem: my arg is input from the web, sort of js data. But  I need pass it to the function in lua.  How could I

achieve that.?  Or can you offer some advice to help, please?

Thank you  in advance.

(Last edited by Wandy on 18 Jun 2014, 02:34)

arg = prompt("Input you number: ")
XHR.poll('<% luci.dispather.build_url("admin", "network", "mine") %>/' + arg, null, callback);
jow wrote:
arg = prompt("Input you number: ")
XHR.poll('<% luci.dispather.build_url("admin", "network", "mine") %>/' + arg, null, callback);

It worked !!   Thank you so much for you time. I really appreciate it.

(Last edited by Wandy on 17 Jun 2014, 13:25)

The discussion might have continued from here.