mirror of
				https://github.com/yiisoft/yii2.git
				synced 2025-11-04 14:46:19 +08:00 
			
		
		
		
	Update yii.js
This commit is contained in:
		@ -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 ($) {
 | 
				
			|||||||
				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 ($) {
 | 
				
			|||||||
	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());
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
		});
 | 
							});
 | 
				
			||||||
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user