head头里面
<meta name="_token" content="{{ csrf_token() }}"/>
ajax
$("#fenhong").on('click', function() {
$.ajax({
type : 'post',
url : '../profile/fenhong',
data : {
},
headers: {
'X-CSRF-TOKEN': $('meta[name="_token"]').attr('content'),
},
dataType : "json",
//在请求之前调用的函数
beforeSend:function(){
alert('即将调用')
},
//成功返回之后调用的函数
success: function(e){
alert('调用成功')
},
// //调用执行后调用的函数
// complete: function(XMLHttpRequest, textStatus){
// alert(XMLHttpRequest.responseText);
// alert(textStatus);
// //HideLoading();
// },
//调用出错执行的函数
error: function(){
//请求出错处理
alert('调用接口出错了');
}
});
})