标签:ssd reset NPU mit rac inpu ade info 技术
顺便实现ajax提交的时候默认提交csrf_token
var http = {
‘get‘:function (args) {
args[‘method‘] = ‘get‘;
this.ajax(args);
},
‘post‘:function (args) {
args[‘method‘] = ‘post‘;
this.ajax(args);
},
‘ajax‘:function (args) { // 将头部信息放到请求
this._ajaxSetup();
$.ajax(args);
},
‘_ajaxSetup‘:function(){ // 将csrftoken放到头部信息
$.ajaxSetup({
‘beforeSend‘: function (xhr, settings) {
if(!/^(GET|HEAD|OPTIPNS|TRACE)$/i.test(settings.type) && !this.crossDomain){
var csrf_token = $(‘meta[name=csrf_token]‘).attr(‘content‘); // 获取csrf_token
xhr.setRequestHeader(‘X-CSRFToken‘, csrf_token)
}
}
});
}
};
修改密码页的js
$(function () {
$(‘#submit‘).click(function (evnet) {
evnet.preventDefault(); //阻止默认的提交表单事件
var oldpwd = $("input[name=‘oldpassword‘]").val();
var newpwd = $("input[name=‘newpassword‘]").val();
var newpwd2 = $("input[name=‘newpassword2‘]").val();
http.post({
‘url‘: ‘/cms/resetpwd/‘,
‘data‘: {
‘oldpwd‘: oldpwd,
‘newpwd‘: newpwd,
‘newpwd2‘: newpwd2,
},
‘success‘: function (data) {
console.log(data);
},
‘fail‘: function (error) {
console.log(error);
}
})
});
});
标签:ssd reset NPU mit rac inpu ade info 技术
原文地址:https://www.cnblogs.com/zhongyehai/p/11914664.html