vendredi 26 décembre 2014

Getting strange errors when making AJAX request


I've been trying to hook up my angular app to it's api but I cannot seem to be able to make calls to it. The page itself work but when I try to make a AJAX call to any file on my server it gives a 404 or [Error] XMLHttpRequest cannot load http://api.test.com/create. Origin http://test.com is not allowed by Access-Control-Allow-Origin..


here is an example of the code i'm using



$.post("http://api.test.com/create", inv).done(function(data) {
console.log(data);
return data;
});


this is currently returning the Access-Control-Allow-Origin. After messing with it, it would sometimes throw a 404.


I'm using the Klein PHP router for the url routing. And I know the page is working because I used Postman (REST client) and sent it requests and they went through.





Aucun commentaire:

Enregistrer un commentaire