如何在Ember js中填充选择字段 App=Ember.Application.create(); App.Router.map(函数(){ //把你的路线放在这里 }); App.IndexRoute=Ember.Route.extend({ 模型:函数(){ 返回App.Item.all(); } }); App.Item=Ember.Object.extend(); App.Item.class({ 全部:函数(){ 返回$.getJSON(“http://localhost/zohobus/gettable.php)然后(函数(响应){ var项目=[]; response.items.forEach(函数(项){ items.push(App.Item.create(Item)); }); 退货项目; }); } }); //index.html的一部分 {{{#模型中的每个项目} {{item.fromm} {{/每个}}

如何在Ember js中填充选择字段 App=Ember.Application.create(); App.Router.map(函数(){ //把你的路线放在这里 }); App.IndexRoute=Ember.Route.extend({ 模型:函数(){ 返回App.Item.all(); } }); App.Item=Ember.Object.extend(); App.Item.class({ 全部:函数(){ 返回$.getJSON(“http://localhost/zohobus/gettable.php)然后(函数(响应){ var项目=[]; response.items.forEach(函数(项){ items.push(App.Item.create(Item)); }); 退货项目; }); } }); //index.html的一部分 {{{#模型中的每个项目} {{item.fromm} {{/每个}},php,json,ember.js,ember-data,ember-cli,Php,Json,Ember.js,Ember Data,Ember Cli,当我有一个返回JSON对象的PHP时,我遇到了错误 我的PHP返回: [{“弗洛姆”:“钦奈”},{“弗洛姆”:“钦奈”},{“弗洛姆”:“马杜赖”},{“弗洛姆”:“马杜赖”},{“弗洛姆”:“钦奈”},{“弗洛姆”:“钦奈”}] 在我的Ember-Chrome工具中,我遇到了这个错误 无法加载XMLHttpRequest。不 “Access Control Allow Origin”标头出现在请求的服务器上 资源。因此,不允许使用源“” 进入 您需要在服务器中设置CORS。请查看以下资源:

当我有一个返回JSON对象的PHP时,我遇到了错误
我的PHP返回:

[{“弗洛姆”:“钦奈”},{“弗洛姆”:“钦奈”},{“弗洛姆”:“马杜赖”},{“弗洛姆”:“马杜赖”},{“弗洛姆”:“钦奈”},{“弗洛姆”:“钦奈”}]

在我的Ember-Chrome工具中,我遇到了这个错误

无法加载XMLHttpRequest。不 “Access Control Allow Origin”标头出现在请求的服务器上 资源。因此,不允许使用源“” 进入


您需要在服务器中设置CORS。请查看以下资源:


这是一个CORS问题,不仅仅是如何填充选择字段。
App = Ember.Application.create();

App.Router.map(function() {
  // put your routes here
});

App.IndexRoute = Ember.Route.extend({
  model: function() {
    return App.Item.all();
  }
});
App.Item = Ember.Object.extend();
App.Item.reopenClass({
  all: function() {
      return $.getJSON("http://localhost/zohobus/gettable.php").then(function(response) {
        var items = [];

        response.items.forEach( function (item) {
          items.push( App.Item.create(item) );
        });

          return items;
      });
  }
});

// Part of index.html

 <script type="text/x-handlebars" id="index">
    <ul>
    {{#each item in model}}
      <li>{{item.fromm}}</li>
    {{/each}}
    </ul>
  </script>