I'm trying to make a simple post request with ajax to a controller in plugin. The problem I'm having is that I always get a 400 Bad request because I don't send a valid CSRF Token.
But I can't figure out how to get this in javascript. I found multiple examples saying you get it by calling
Craft.getCsrfInput();
but this only works in "CP mode", on the front-end the Craft object is not available. I also found that importing it is not a good idea.
So anyone who can tell me how to do this?