質問

ローカル環境を設定します。ここで、JSONファイルからデータをロードします。

var Players = $resource('data/players.json');
var players = Players.query(function(){});
.

働く。

今、異なるドメイン(http://playball.iriscouch.com/players)でCouchDBにアクセスし、Google Buzzの例に基づいて、次のようにしてみましたが、それを作業することはできません:

var Players = $resource('http://playball.iriscouch.com/players',  
  {alt: 'json', callback: 'JSON_CALLBACK'},
  {get:     {method: 'JSON'}
});

var players = Players.query(function(){});
.

単に空の配列を受け取る...任意のアイデア?

Buch!

Sune

役に立ちましたか?

解決

サーバーを制御している場合は、 cors

あなたの例を修正するには:

var Players = $resource('http://playball.iriscouch.com/players',

  // These params will be set to each request (?alt=json&callback=JSON_CALLBACK),
  // where JSON_CALLBACK placeholder will be replaced with correct callback fn,
  // generated by Angular.
  {alt: 'json', callback: 'JSON_CALLBACK'},

  // You need to configure query method to use JSONP
  {query:     {method: 'JSONP'}
});

var players = Players.query(function(){});
.

サーバが正しいデータ(Dev Toolbar - ネットワークパネル)を応答しているか確認してください。

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top