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>
I am getting Error when I have a PHP that returns JSON object
my PHP returns :
[{"fromm":"Chennai"},{"fromm":"Chennai"},{"fromm":"Madurai"},{"fromm":"Madurai"},{"fromm":"Chennai"},{"fromm":"Chennai"}]
In my Ember -Chrome tool i get this error
XMLHttpRequest cannot load http://localhost/zohobus/gettable.php . No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin ' http://localhost:8080 ' is therefore not allowed access.
You need to setup CORS in your server. Have a look at these resources:
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.