I have a wcf service runing which contains a method that returns a string. I am able to run the service in the browser successfully. Moreover I can even pass the required parameters and can see the result in the browser.
But when i am trying to invoke the same method from javascript client the parameter value does not get passed to the method and hence it returns nothing.
Here is what my service retuns when run from the browser

Here is my interface Implementation:
[OperationContract]
[WebInvoke(Method = "GET",
ResponseFormat = WebMessageFormat.Json,
BodyStyle = WebMessageBodyStyle.Wrapped)]
string JSONData(string id);
Here is my service Method implementation code:
public string JSONData(string id)
{
if (id == null || id == "")
{
return "Id is null";
}
else
{
return "You requested product " + id;
}
}
As shown above service works fine fine a parameter is passed from the url. However when I make the call using jquery's function parameter doesnot get passed Here is my javascript client's code:
<script type="text/javascript">
// A $( document ).ready() block.
$(document).ready(function () {
// alert("pass");
var valu = "123";
$("#btnclick").click(function () {
debugger;
$.ajax({
cache: false,
type: "GET",
async: false,
url: "http://localhost:35798/RestServiceImpl.svc/JSONData",
data: JSON.stringify(valu),
contentType: "application/json",
dataType: "json",
success: function (result) {
var ans = JSON.stringify(result);
alert("success");
alert(ans);
},
error: function (xhr) {
alert("error");
alert(xhr.responseText);
}
});
});
});
</script>
I want to be able to pass the parameter from the jquery code. Any suggestions to get this working would be really appreciated.