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"}] */ 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.
Aucun commentaire:
Enregistrer un commentaire