To solve the CSRF problem, I use a client-side setup for Ajax:
$.ajaxSetup({
beforeSend: function(xhr, settings) {
function getCookie(name) {
Use $(document).ajaxSend(function(ev, jqhr, settings) { ... })
instead of .ajaxSetup
.
As you said .ajaxSetup
defines a default handler which then can be overriden. With .ajaxSend
you can register multiple handlers to fire before an ajax request is sent. Works fine with custom beforeSend
handler.