从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; });更多推荐
发布评论