Hello,
I have a WCF service that accepts requests from JQuery. Currently, I can access this service. However, the parameter value is always null. Here is my WCF Service definition:
[OperationContract]
[WebInvoke(Method = "GET", BodyStyle = WebMessageBodyStyle.WrappedRequest, RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json)]
public string ExecuteQuery(string query)
{
// NOTE: I get here, but the query parameter is always null
string results = Engine.ExecuteQuery(query);
return results;
}
Here is my JQuery call:
var searchUrl = "/services/myService.svc/ExecuteQuery";
var json = { "query": eval("\"test query\"") };
alert(json2string(json)); // Everything is correct here
if (json != null) {
$.ajax({
type: "GET",
url: searchUrl,
contentType: "application/json; charset=utf-8",
data: json2string(json),
dataType: "json"
});
}
What am I doing wrong? It seems odd that I can call the service but the parameter is always null. Thank you