I am creating a simple JSON API that just returns me an object using jsonp using node-js Here is the code for server side :
app.get('/vit',function (req,res,next) {
res.type('application/json');
res.jsonp(items); //items is the object
});
On deploying to nodejitsu , and going to url /vit i get the object items.That means its working on the server side.
I have another domain from where I wanna get this object using jsonp Heres the client-side code :
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script type="text/javascript">
$.getJSON('http://trial.jit.su/vit',function (data) {
console.log(data) ;
});
</script>
But I get the following error on the console:
XMLHttpRequest cannot load http://trial.jit.su/vit. Origin http://jquer.in is not allowed by Access-Control-Allow-Origin.
Seems like I have not understand Jsonp.