I'm trying to post JSON data from JQuery to a cross domain WCF 4.0 REST service and cannot get past the cross domain aspect. Here's my REST method:
[OperationContract]
[WebInvoke(Method = "*",
BodyStyle = WebMessageBodyStyle.Bare,
RequestFormat = WebMessageFormat.Json
ResponseFormat = WebMessageFormat.Json,
UriTemplate = "Save")]
DataContract Save(DataContract dataContract);
Here's my jQuery code:
$.ajax(
{
type: 'POST',
url: url,
data: JSON.stringify(data),
dataType: 'json',
contentType: 'application/json',
success: function(data)
{
alert('success');
},
error:function (xhr, ajaxOptions, thrownError)
{
alert(xhr.status);
alert(thrownError);
} });
I've stumbled across this post but could not get it to work. Please help.
Thanks
Tom