JS post not working?

Hi,
I’m trying to make a simple doorlock creator, but I ran into a problem

debug.lua: debug.lua - Pastebin.com
index.js: index.js - Pastebin.com
index.html: index.html - Pastebin.com

After clicking Inject button it should print doorlock code in textbox.
obraz_2023-08-06_180950461

Have you tried adding here a console.log to check if the value isn’t empty?
image

$("#easy-nots-inject").click(function() {
    console.log("Attempting to trigger the click function.");

    $.post('https://easyadmin/injectUI', JSON.stringify({ code: $(".easy-nots-input").val() }))
        .done(function(response) {
            console.log("Success! Server response:", response);
        })
        .fail(function(error) {
            console.error("An error occurred while sending the request:", error);
        });
});

I meant to log the $(".easy-nots-input").val() 'cause it seems to be an empty string.
//
And btw if I were on your place I would use id instead of class to get the value, so in HTML I would replace
<textarea class="easy-nots-input" spellcheck="false"></textarea>
with
<textarea id="injectInput" class="easy-nots-input" spellcheck="false"></textarea>

and in JS replace
$.post('https://easyadmin/injectUI', JSON.stringify({ code: $(".easy-nots-input").val() }))
with
$.post('https://easyadmin/injectUI', JSON.stringify({ code: document.getElementById("injectInput").value}))

$("#easy-nots-inject").click(function() {
    console.log("Attempting to trigger the click function.");
    var inputValue = $(".easy-nots-input").val();
    console.log("Input value:", inputValue);

    $.post('https://easyadmin/injectUI', JSON.stringify({ code: inputValue }))
        .done(function(response) {
            console.log("Success! Server response:", response);
        })
        .fail(function(error) {
            console.error("An error occurred while sending the request:", error);
        });
});

So now do you see what’s wrong? If think that if you would do what I said in my previous message, the code will work :smiley: