Commit 75fb2614 by Dilip

Update yii.js

parent e87220be
...@@ -60,8 +60,8 @@ yii = (function ($) { ...@@ -60,8 +60,8 @@ yii = (function ($) {
/** /**
* @return string|undefined the CSRF variable name. Undefined is returned if CSRF validation is not enabled. * @return string|undefined the CSRF variable name. Undefined is returned if CSRF validation is not enabled.
*/ */
getCsrfVar: function () { getCsrfParam: function () {
return $('meta[name=csrf-var]').prop('content'); return $('meta[name=csrf-param]').prop('content');
}, },
/** /**
...@@ -130,9 +130,9 @@ yii = (function ($) { ...@@ -130,9 +130,9 @@ yii = (function ($) {
if (!method.match(/(get|post)/i)) { if (!method.match(/(get|post)/i)) {
$form.append('<input name="_method" value="' + method + '" type="hidden">'); $form.append('<input name="_method" value="' + method + '" type="hidden">');
} }
var csrfVar = pub.getCsrfVar(); var csrfParam = pub.getCsrfParam();
if (csrfVar) { if (csrfParam) {
$form.append('<input name="' + csrfVar + '" value="' + pub.getCsrfToken() + '" type="hidden">'); $form.append('<input name="' + csrfParam + '" value="' + pub.getCsrfToken() + '" type="hidden">');
} }
$form.hide().appendTo('body'); $form.hide().appendTo('body');
} }
...@@ -199,7 +199,7 @@ yii = (function ($) { ...@@ -199,7 +199,7 @@ yii = (function ($) {
function initCsrfHandler() { function initCsrfHandler() {
// automatically send CSRF token for all AJAX requests // automatically send CSRF token for all AJAX requests
$.ajaxPrefilter(function (options, originalOptions, xhr) { $.ajaxPrefilter(function (options, originalOptions, xhr) {
if (!options.crossDomain && pub.getCsrfVar()) { if (!options.crossDomain && pub.getCsrfParam()) {
xhr.setRequestHeader('X-CSRF-Token', pub.getCsrfToken()); xhr.setRequestHeader('X-CSRF-Token', pub.getCsrfToken());
} }
}); });
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment