API REST JQUERY
API REST JQUERY
我想在这个站点上使用API jquery.rest(例如),我在控制台上执行任何操作。这是我的脚本
var client = new $ RESTClient ('http://api.openweathermap.org/data/2.5/weather?lat=35&lon=139');
client.show ();
我的控制台上没有显示任何内容
嗨,为什么不尝试使用jsonp
dataType使用jQuery的内置$.ajax()
调用?参见此处
这是我成功的尝试:
var URI = 'http://api.openweathermap.org/data/2.5/weather?lat=35&lon=139';
$.ajax({url:URI,dataType:"jsonp"})
.done(function(object){
//now you can access your object like any other json object e.g.
alert(object.sys.country);
})
.fail(function(){
alert("oh no - something went wrong!");
});
希望这能有所帮助!
如果您使用的是:https://github.com/jpillora/jquery.rest然后看起来你的大写错误了。
尝试:
var client = new $.RestClient('http://api.openweathermap.org/data/2.5/weather?lat=35&lon=139');
client.show();
奶昔的反应就是你想要的。-为了满足您的需要,我正在将您的json对象转换为字符串,这样您就可以有更好的想法。
var URI = 'http://api.openweathermap.org/data/2.5/weather?lat=35&lon=139';
$.ajax({url:URI,dataType:"jsonp"})
.done(function(object){
//now you can access your object like any other json object e.g.
alert(JSON.stringify(object));
})
.fail(function(){
alert("oh no - something went wrong!");
});
相关文章:
- SharePoint 2010 Jquery/JSON Rest Multiple OR语句-如何
- jQuery REST会话没有'不工作,但在POSTMan工作
- 如何在带有JQuery的Neo4j 2.2.x中使用事务Cypher HTTP端点和新的REST API身份验证和授权
- 从jquery调用REST服务
- JQuery REST 调用不起作用
- Rest api get call using jquery
- 如何使用 Ajax + jQuery 调用基于 Web 服务 REST
- jQuery Post Callback from REST API
- Jquery ajax 在调用 rest Web 服务时失败
- 标准的XMLHttpRequest有效,但在发布到REST服务时jQuery$.ajax无效
- 如何使用JQuery从REST API仅返回JSON对象的一部分
- 使用javascript Rest api或jquery的Sharepoint身份验证
- API REST JQUERY
- 使用Jquery/javascript调用REST服务
- 如何通过jQuery从JIRA REST API获取和发布数据
- 需要使用Javascript/JQuery使用Rest API XML响应
- 使用jQuery进行API Rest调用
- 在JQuery中使用POST时,在REST资源上获取null值
- 使用Jquery更新函数REST
- 为什么Jquery rest未定义