如何使用JSONP在Bintray上获取工件的最新版本 [英] How to get latest version of a artifact on Bintray using JSONP

查看:71
本文介绍了如何使用JSONP在Bintray上获取工件的最新版本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Bintray提供了REST API来搜索具有最新版本信息的工件:

Bintray provide a REST API to search a artifact with latest version infomation:

https://api.bintray.com/search/packages/maven?q=&g=me.tankery.lib&a=circularSeekBar

我正在努力寻找一种使用Javascript代码在Bintray上获取工件最新版本的方法.

I'm trying hard to find a way to get latest version of a artifact on Bintray with Javascript code.

似乎Bintray服务器不支持CORS,我使用JSONP通过jQuery请求数据:

Seems Bintray server not support CORS, I use JSONP to request the data with jQuery:

var url = "https://api.bintray.com/search/packages/maven?q=&g=me.tankery.lib&a=circularSeekBar";
$.getJSON(url, function(response) {
    console.log(response);
});

但是没有收到回复.我在Chrome Dev Tools中检查了响应,注意Bintray REST API的响应在其JSON数据上没有填充.因此,JSONP的回调函数永远不会调用.

But the response never received. I check the response in Chrome Dev Tools, notice that the response of Bintray REST API has no padding on its JSON data. So the JSONP's callback function never invoke.

当服务器不支持JSONP时我可以做什么?

What things I can do when server don't support JSONP?

推荐答案

自己提供一个后端,该后端可以为您下载所需的数据,并且不受Same-Origin-Policy的约束.

Provide a backend yourself which downloads the required data for you and is not subject to the Same-Origin-Policy.

这篇关于如何使用JSONP在Bintray上获取工件的最新版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆