I have a file under webroot folder out of cakephp default installation and I want to get a json response back. But when I try to do that I get this error
XMLHttpRequest cannot load http://test.com/companies/all_company_information. Origin http://dev.local is not allowed by Access-Control-Allow-Origin.
$.ajax({
type: 'POST',
url: '/controller/method',
dataType: 'json',
success: function(data){
console.log(data);
}
});
I have read up on some of the info on google but I think I am not understanding this.
EDIT
when I use jsonp I get this error
Resource interpreted as Script but transferred with MIME type text/html:
$.ajax({
type: 'POST',
url: '/controller/method',
dataType: 'jsonp',
success: function(data){
console.log(data);
}
});
Try creating a function in an appropriate controller that is setup to respond with the intended json. A controller configured to respond with json:
I use the firefox extension firebug heavily in order to ensure my ajax requests are going through and what their responses are.