jQuery.each(["get", "post"], function (i, method) { jQuery[method] = function (url, data, callback, type) { if (jQuery.isFunction(data)) { type = type || callback; callback = data; data = undefined; } return jQuery.ajax({ url: url, type: method, dataType: 'json', contentType: 'application/json', data: JSON.stringify(data), success: callback, beforeSend: function (xhr) { xhr.setRequestHeader("SignsValue", "签名-----------模拟"); xhr.setRequestHeader("TimeStamp", "时间戳---------模拟"); } }); }; });
对$.post跟$.get重新封装,将签名和时间戳传递到Header中
最新推荐文章于 2024-09-22 22:23:58 发布