I've followed this old guide which didnt work, probably due to it being for Craft 2, so I modified it to what I assumed would work.
I changed the /actions/tags/createTag to /actions/tags/create-tag as apparently this is what Craft 3 needs.
I also updated the code to include the CSRF token when posting data via jQuery.post() as well using this Craft guide
But I was still getting errors with the following code
I got a 400 bad request and it says 'unable to verify your data submission'
So I turn off CSRF protection in the general just to see if anything else is wrong.
Then I get a different bad request saying 'Bad Request: Request must accept JSON in response'...
So I have no idea what or why this isn't working. I also altered the orignal code to JSON.stringify the data as originally I was getting an error that I had to send in JSON.
Anyway I can't work out what else is wrong so would love some help.