I am working on creating a new set of services in ASP.MVC MVC 4 using the Web API. So far, it's great. I have created the service and gotten it to work, and now I am trying to consume it using JQuery. I can get back the JSON string using Fiddler, and it seems to be ok, but because the service exists on a separate site, trying to call it with JQuery errors with the "Not Allowed". So, this is clearly a case where I need to use JSONP.
I know that the Web API is new, but I'm hoping someone out there can help me.
How do I make a call to a Web API method using JSONP?
Best Answer
After asking this question, I finally found what I needed, so I am answering it.
I ran across this JsonpMediaTypeFormatter. Add it into the
Application_Start
of your global.asax by doing this:and you are good to go with an JQuery AJAX call that looks like this:
It seems to work very well.