对$.post跟$.get重新封装,将签名和时间戳传递到Header中

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/qq_33008701/article/details/55259570
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", "时间戳---------模拟");
            }
        });
    };
});

猜你喜欢

转载自blog.csdn.net/qq_33008701/article/details/55259570