weixin_33726318 2015-03-24 08:53 采纳率: 0%
浏览 98

Ajax Oauth 2.0访问令牌

Im trying to create a JSON request and I have the below script, for some reason I don't get a response. Can anyone help with this?

I haver my token but I have no idea where I need to put it?

    <script>
    $.ajax(
        'https://data.brightcove.com/analytics-api/videocloud/accounts/867903724001/report/?dimensions=video&format=json', {
            type: 'GET',
            dataType: 'json',
            beforeSend: function(xhr) {
                xhr.setRequestHeader("Authorization", "Bearer $token")
            },
            complete: function(resp) {
                console.log(resp);
            },
            error: function(jqXHR, textStatus, errorThrown) {
                console.log(textStatus);
            }
        }
    );
</script>
  • 写回答

1条回答 默认 最新

  • weixin_33720078 2015-03-24 08:58
    关注
     $.ajax({
            url: 'https://data.brightcove.com/analytics-api/videocloud/accounts/867903724001/report/?dimensions=video&format=json',
          dataType: 'JSONP',
         beforeSend: function(xhr) {
                    xhr.setRequestHeader("Authorization", "Bearer $token")
                },
          success: function(data){
            console.log(data)
          },
         error: function(jqXHR, textStatus, errorThrown)   {
                        console.log(textStatus);
                    }
    
        })
    

    Change datatype json to jsonp. Since you trying to access cross domain you have to use jsop.

    评论

    报告相同问题?

    悬赏问题

    • ¥15 编译arm板子的gcc
    • ¥20 C语言用栈实现无向图邻接矩阵广度优先遍历
    • ¥15 C++代码报错问题,c++20协程
    • ¥15 c++图Djikstra算法求最短路径
    • ¥15 Linux操作系统中的,管道通信问题
    • ¥15 ansible tower 卡住
    • ¥15 等间距平面螺旋天线方程式
    • ¥15 通过链接访问,显示514或不是私密连接
    • ¥100 系统自动弹窗,键盘一接上就会
    • ¥50 股票交易系统设计(sql语言)