I am working on a Laravel 5 app that has CSRF protection enabled by default for all POST requests. I like this added security so I am trying to work with it.
While m
I think that above solution might not work as well. When you do:
var x;
x + ""
// "undefined" + empty string coerces value to string
You will get data like "undefined_token=xxx"
When you use the above solution for laravel's delete for instance you have to check like this:
if (typeof options.data === "undefined")
options.data = "";
else
options.data += "&";
options.data = "_token=" + csrf_token;