Hello.
Today I've been trying to create HTML-based login panel for my server. Everything is set up, but it seems like the Ajax requests can't be handled. I've tested if JavaScript works and if the requests themselves are sent and it seems like both JavaScript works and requests are sent.
Lua:
local screenW, screenH = guiGetScreenSize()
local webBrowserGUI = guiCreateBrowser(500, 500, screenW, screenH, true, false, false)
local webBrowser = guiGetBrowser(webBrowserGUI)
setBrowserAjaxHandler(webBrowser, "index.html", function(get, post)
for k, v in pairs(get) do
print(string.format("REQUEST %s = %s", k, v))
end
end)
addEventHandler("onClientBrowserCreated", webBrowser, function()
loadBrowserURL(webBrowser, "http://mta/local/files/index.html")
guiSetInputEnabled(true)
showCursor(true)
toggleAllControls(false)
end)
HTML:
<html lang="pl">
<head>
<meta charset="utf-8"/>
</head>
<body>
<section>
<table>
<tr>
<td style="width: 10%">Nick:</td>
<td><input type="text" id="nick"/></td>
</tr>
<tr>
<td>Password:</td>
<td><input type="password" id="password"/></td>
</tr>
</table>
<button id="login">Login</button>
<button id="register">Register</button>
</section>
</body>
<script>
const nick = document.getElementById("nick")
const password = document.getElementById("password")
const login = document.getElementById("login")
const register = document.getElementById("register")
login.addEventListener("click", () => {
const xhr = new XMLHttpRequest()
xhr.open("GET", `http://mta/local/files/index.html?nick=${nick.value}&password=${password.value}&method=login`)
xhr.send()
})
register.addEventListener("click", () => {
const xhr = new XMLHttpRequest()
xhr.open("GET", `http://mta/local/files/index.html?nick=${nick.value}&password=${password.value}&method=register`)
xhr.send()
})
</script>
</html>