I am attempting to send an array from JavaScript to a XHR GET request in Luci OpenWrt.
Let's say, we have an array named myarray[] with some contents like this: `myarray[] = {"1","2","3"}`
I want to pass this array as arguments to the XHR.get
requests. How can I achieve this?
Here is a sample code snippet:
XHR.get('<%=REQUEST_URI%>', {status: 2,value: myarray},
function(x, info) {
if (!info) {
location.href=location.href;
}
else {
console.log("success");
}
}
);
In Lua code, I am then receiving this form data:
If luci.http.formvalue("status") == "2" then
local DetailValue[] = luci.http.formvalue("value")
local fileContent = {
content = "sample1",
find = "sample2"
}
luci.http.prepare_content("application/json")
luci.http.write_json(fileContent)
return
end
However, I am encountering errors. Is this the correct way to send an array via XHR.get? Any suggestions would be appreciated.