jquery ajax post请求在header中添加属性

5,814 阅读1分钟
var params = {
          quantity:this.buyPoints,
        }
        var that = this
        $.ajax({
          url: this.urlDoMain + 'company_point_allocation/getDetails',
          data: JSON.stringify(params),
          contentType: "application/json",
          type: "post",
          // 设置头部属性
          beforeSend: function(request) {
            request.setRequestHeader("Test", "yang");
          },
          success: function (data) {
          }
        })