I'm pretty sure JSONP means no cross domain restrictions. I'm trying to make a JSONP service using node and express. Here is simple code:
self.routes['/portfolio'] = function(req, res) {
// Website you wish to allow to connect
res.jsonp({ "my": "object" });
};
When I do:
$.getJSON('http://127.0.0.1:8080/portfolio', function(data){ console.log(data)});
I get this error.
XMLHttpRequest cannot load http://127.0.0.1:8080/portfolio. The 'Access-Control-Allow-Origin' header has a value 'http://127.0.0.1:8080/portfolio' that is not equal to the supplied origin. Origin 'http://api.jquery.com' is therefore not allowed access.
Can someone explain what is going on here? Why do we need to supply header value if this is JSONP. How can I make this work cross domain?