For anyone with the same problem as me here’s the solution i found

To take data back from javascript you use this line in your js file

$.post("http://resourcename/eventname", JSON.stringify({ pass variables }))

and on your frontend you use

RegisterNUICallback('testevent', function(data)
    print(data)
end)
1 Like