使用Ember和Ember-Model開發一個調用Spring/Rest/MongoDB後端的前端,這些後端都在我的本地機器上運行,用於開發目的,但是我得到我的電話會出現相同的來源策略錯誤。在本地機器上開發的同源策略
我想知道這是什麼共同的工作。
這裏是我的代碼:
App = Ember.Application.create();
App.Router.map(function(){
});
App.IndexRoute = Ember.Route.extend({
model: function(){
return App.User.find();
}
});
App.User = Ember.Model.extend({
lastName: Ember.attr()
});
App.User.adapter = Ember.Adapter.create({
findAll: function(klass, records) {
$.getJSONP("http://localhost:8080/users").then(function(data) {
records.load(klass, data.users);
});
}
})
如果你調用$ .getJSONP(「用戶」),而不是你得到了同樣的錯誤? – bhspencer 2015-02-07 20:16:35
@ .getJSONP實際上根本不工作。它不存在於Ember中(或者這是一個JQuery的東西嗎?我不知道)。這是我試圖解決這個問題。所以實際的調用是$ .getJSON。我試過這個:「/ users」,它是尋找「file:/// C:/ users」,我甚至創建了一個名爲users.json的JSON文件,然後嘗試使用:「/users.json」,但這也失敗了:( – 2015-02-08 02:05:08