weixin_33734785 2015-11-03 14:23 采纳率: 0%
浏览 3

$ .ajax()到$ .getJSON()

I would like to ask if there is a method to parse data from $.ajax() to $.getJSON() please?

This is the $.ajax() example:

var apiUrl = 'https://api.com/url_here';
var apiKey = 1234567890;
var apiSecret = 0987654321;

var data = {};

$.ajax({
  url: apiUrl,
  headers: {
    "Authorization": "Basic " + btoa(apiKey+ ":" + apiSecret)
  },
  data: data,
  dataType: 'json',
  type: 'GET',

  success: function(data) {
    console.log(data);
  },

  error: function(data) {
    console.log(data);
  }
});

And this is what I have in my $.getJSON(), where I have a struggle in calling the headers for authentication:

    $.getJSON(apiUrl, function(json){

        console.log(JSON.stringify(json));

    });

Thanks a lot! xxx

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 c程序不知道为什么得不到结果
    • ¥40 复杂的限制性的商函数处理
    • ¥15 程序不包含适用于入口点的静态Main方法
    • ¥15 素材场景中光线烘焙后灯光失效
    • ¥15 请教一下各位,为什么我这个没有实现模拟点击
    • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
    • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
    • ¥20 有关区间dp的问题求解
    • ¥15 多电路系统共用电源的串扰问题
    • ¥15 slam rangenet++配置