我想从JQuery发布JSON数据到跨域WCF 4.0 REST服务,并且无法通过跨域方面。这里是我的休息方法:jQuery跨域发布到WCF 4.0 REST服务
[OperationContract]
[WebInvoke(Method = "*",
BodyStyle = WebMessageBodyStyle.Bare,
RequestFormat = WebMessageFormat.Json
ResponseFormat = WebMessageFormat.Json,
UriTemplate = "Save")]
DataContract Save(DataContract dataContract);
这里是我的jQuery代码:
$.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);
} });
我偶然发现this post但无法得到它的工作。请帮忙。
感谢
汤姆