Possible Duplicate:
Ajax cross domain call
I have Asp.Net Controller methods which return JSON response. However I am unable to call it from a different domain using Jquery’s $.getJSON(...){}
Quick googling suggests that JSONP must be used. Question is what is the difference between JSON and JSONP? Is that just another new term? And if JSONP is working why I can’t I make JSON work? Is there any way to not use these fancy JSONP and use plain old JSON because I am afraid of any changes to my server side code.
You cannot make cross domain AJAX calls using JSON. You need to use JSONP. So instead of returning a regular
JsonResultfrom your controller action write a custom action result that will wrap the JSON in a callback that is passed as parameter:and then have your controller action return this custom action result:
Now you could consume this action cross domain: