i can't conect my server web2py restful with angular Ajax, but if i set the url in my browser it's fine it work , but i cant in angular ajax =(
Link of Angular
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.16/angular.min.js"></script>
<script src="https://code.angularjs.org/1.3.16/angular-route.min.js"></script>
Mi code in my server web2py (Controller)
@request.restful()
def api():
response["Access-Control-Allow-Origin"] = "*"
response["Access-Control-Allow-Methods"] = "POST, GET, OPTIONS"
response["Access-Control-Max-Age"] = "1000"
response["Access-Control-Allow-Headers"] = "*"
response.view = 'generic.json'
def GET():
print "asdasds"
return dict(content="JAJAJAJAJA")
return dict(GET=GET)
and mi AJax in angular url= Address:port/nameProject/controller/action
app.controller('controlVentas', function( $http) {
var app = this;
app.CargarLlave=function(){
var respuesta=$http.get("http://127.0.0.1:8000/Hoteles/ControlMSR/api");
respuesta.success(function(data){
alert( "OK");
});
respuesta.error(function(data, status, headers, config){
alert( "NOOOOO");
});
}
});
error of angular
XMLHttpRequest cannot load http://127.0.0.1:8000/Hoteles/ControlMSR/api. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://127.0.0.1:57734' is therefore not allowed access.