function getUserInfo(data) { return $.ajax({ type: "POST",url: "/user",dataType: "json",contentType: "application/json;utf-8",data: data,timeout: 6000 }); } getUserInfo(data) .done(function (response) { alert(response); }) .fail(function () { //error });
备注:在上面的方法中如果使用post方式,后台有可能获取不到数据,把contentType: "application/json;utf-8",删除即可
原文链接:https://www.f2er.com/ajax/161761.html