从url获取json数据(Get json data from url)

编程入门 行业动态 更新时间:2024-10-28 15:22:56
从url获取json数据(Get json data from url)

我有以下部分代码可以正常工作。 现在我想从特定网址获取我的“列表”,其中包含json数据的响应。

(function() { var app, list; list = [ { 'name': 'Foo', 'title': 'Designer' },{ 'name': 'Bar', 'title': 'Designer' } ];

simple list = $http.get('/data_url/').success(function(data)); 不工作。

I have following part of code which works fine. Now I want to get my "list" from specific url which response with json data.

(function() { var app, list; list = [ { 'name': 'Foo', 'title': 'Designer' },{ 'name': 'Bar', 'title': 'Designer' } ];

simple list = $http.get('/data_url/').success(function(data)); do not work.

最满意答案

$http.get函数不返回数据。 您可以使用成功回调中的响应数据进行处理。

你必须像这样设置数据:

$http.get('/data_url/').then(function(data){ list = data; });

The $http.get function does not return the data. You can handle with the response data in the success callback.

You have to set the data like this:

$http.get('/data_url/').then(function(data){ list = data; });

更多推荐

本文发布于:2023-08-01 10:54:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1357324.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:数据   url   json   data

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!