jquery ajax 回调函数

function test(callback){
$.ajax({
url:'/mall/credit',
type: 'get',
dataType:'json',

processData: false, // 告诉jQuery不要去处理发送的数据
contentType: false, // 告诉jQuery不要去设置Content-Type请求头

success: function(response){
credit = response.data.credit;
callback(credit);
},
error: function(){
alert("error");
}
});
}
test(function(data){
console.log(data);
})

原文地址:https://www.cnblogs.com/cosyer/p/6374628.html