ajax请求添加自定义header参数

阅读次数: 550

  • A+
所属分类:JS 建站 语言学习
$.ajax({
             type: "post",
             url:"http://127.0.0.1:4564/bsky-app/template/testPost",
             contentType: "application/json;charset=utf-8",
             data :JSON.stringify({"bodyName":"sdfsdf","date":"2017-11-28 07:34:01","price": 10.5,"tbId": 1}),
             dataType: "json",
             beforeSend: function (XMLHttpRequest) {
         		XMLHttpRequest.setRequestHeader("token", "eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiIxOD.....");
             },
             success: function (data) {
            	 alert(data);
             },error:function(error){
                 console.log(error);
             }
         });
  • 我的微信
  • 这是我的微信扫一扫
  • weinxin
  • 我的微信公众号
  • 我的微信公众号扫一扫
  • weinxin

发表评论

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: