MPExtended/MPExtended — Issue #154: Enable JSONP in WCF (feature request)
Author: augustinmarx
Created: 2012-01-24 10:20:22+00:00
State: open

To enable access to the services via JSONP (eg. to use it via jQuery getJSON) it would useful to enable JSONP. Which can be done by adding the crossDomainScriptAccessEnabled="true" attribute to the webHttpBinding.

In file MPExtended / Libraries / MPExtended.Libraries.Service / Hosting / App.config change

to

Then the services can be accessed like this
http://localhost:4322/MPExtended/TVAccessService/json/GetServiceDescription?callback=callbackfunc
which causes the JSON data to be encapsulated in a function call to callbackfunc. This javascript function can than process the returned data.
The response to the http request would then look like this:
callbackfunc({"ApiVersion":2,"HasConnectionToTVServer":true,"ServiceVersion":"0.4.1"});

For info on JSONP: http://en.wikipedia.org/wiki/JSONP
For info on JSONP and WCF: http://msdn.microsoft.com/en-us/library/ee834511.aspx
For info on jQuery and JSON: http://api.jquery.com/jQuery.getJSON/