JQuery AJAX and WCF error after POST request
I am trying to send some JSON to my WCF services from a $ .ajax request. Here's my set of parameters:
$.ajax(
{
type: "POST",
url: theurl,
data: '{name:"Gabriel"}',
dataType: "json",
async:false,
timeout: 5000,
//success and error callbacks here...
The WCF method contract looks like this:
[OperationContract]
[WebInvoke(Method = "*",
RequestFormat = WebMessageFormat.Json,
BodyStyle = WebMessageBodyStyle.Bare,
UriTemplate = "/Sample/POST")]
string postSample(Stream jsondata);
WCF runs on a remote server (cross-domain and Access-Control-Allow-Origin features are available here). When I debug using w3wp.exe I can see that WCF methods get through, POST body is correct, but after service method returns (plain JSON or empty string) I get
[Exception... "Failure"...> :: line 4" data: no]
in Firefox. Safari and Chrome throws:
Error: NETWORK_ERR: XMLHttpRequest Exception 101
I am using VS2010 and jQuery 1.7.xx
Any idea what I am doing wrong? Any suggestion would be really appreciated.
+3
source to share