//jquery版 发同步请求 ?function getData(url,param,fn){ ???var Authorization=localStorage.getItem("Authorization"); ???var commonParam={ ?????"portalType": "PC_MID", ?????"reqTime": new Date().getTime(), ???} ???for(var key in commonParam){ ?????param[key]=commonParam[key] ???} ???$.ajax({ ?????type: ‘post‘, ?????async: false, ?????timeout: 10000, // 超时时间 10 秒 ?????headers: { ???????"Authorization":Authorization ?????}, ?????dataType:‘json‘, ?????contentType: ‘application/json;charset=UTF-8‘, ?????url: url, ?????data: JSON.stringify(param), ?????success: function(data) { ???????fn(data) ?????}, ?????error: function(err) { ?????}, ?????complete: function(XMLHttpRequest, status) { //请求完成后最终执行参数 ?????} ???}) ?}
jquery版 发同步请求 自定义头部信息 公共请求体
原文地址:https://www.cnblogs.com/lguow/p/10336965.html