How can I pass request headers with jQuery's getJSON() method?

前端 未结 3 705
迷失自我
迷失自我 2020-12-04 17:07

I need to do a getJSON() request, but how do I pass authorisation and custom headers?

I am getting issues that the request header is taking the name, bu

3条回答
  •  猫巷女王i
    2020-12-04 17:49

    I think you could set the headers and still use getJSON() like this:

    $.ajaxSetup({
      headers : {
        'Authorization' : 'Basic faskd52352rwfsdfs',
        'X-PartnerKey' : '3252352-sdgds-sdgd-dsgs-sgs332fs3f'
      }
    });
    $.getJSON('http://localhost:437/service.svc/logins/jeffrey/house/fas6347/devices?format=json', function(json) { alert("Success"); }); 
    

提交回复
热议问题