Fork me on GitHub

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);
})

posted @ 2017-02-07 16:13  cosyer  阅读(211)  评论(0)    收藏  举报