Last post Apr 15, 2014 01:26 PM by damienBod
Apr 11, 2014 04:15 PMfirstname.lastname@example.org|LINK
I am using the Web API 2 - REST/JSON controller (which BTW makes writing a REST server trivial - awesome).
I'm now hitting a problem. When I make a JSONP request, I think my server is still returning JSON and JQuery on the client side is hitting a parse error. On the client side the returned object e.responseText is the JSON I requested. But it calls fail (e,
f, g) where g.message is "unexpected token :"
Is there some setting I need to have it look to see if the request is for JSON vs JSONP and return the appropiate wrapper if needed?
thanks - dave
Apr 11, 2014 06:05 PM|damienBod|LINK
Use the WebAPIContrib JSONP NuGet package. This also has samples. You could also possibly config CORS instead of using jsonp.
Apr 15, 2014 10:49 AMemail@example.com|LINK
First, thank you. Second, which is better - CORS or JSONP?
Apr 15, 2014 01:26 PM|damienBod|LINK
here's an answer to your question.
I would use CORS whenever you can. CORS is now very easy to use.