generated from jric11/baseProject
Codex's updates...
This commit is contained in:
+14
@@ -1,3 +1,17 @@
|
||||
// Attach the session CSRF token to existing forms and same-origin AJAX requests.
|
||||
$.ajaxPrefilter(function (options, original, xhr) {
|
||||
if (!options.crossDomain && !/^(GET|HEAD|OPTIONS)$/i.test(options.type)) {
|
||||
xhr.setRequestHeader('X-CSRF-Token', $('meta[name="csrf-token"]').attr('content') || '');
|
||||
}
|
||||
});
|
||||
$(function () {
|
||||
$('form[method="post" i]').each(function () {
|
||||
if (!$(this).find('[name="csrf_token"]').length) {
|
||||
$('<input>', {type: 'hidden', name: 'csrf_token', value: $('meta[name="csrf-token"]').attr('content') || ''}).appendTo(this);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
// ==============
|
||||
// Base Functions
|
||||
|
||||
Reference in New Issue
Block a user