I have a very simple WCF Service called pilltrkr.svc. I\'m trying to call this service from jQuery via the following code:
var jsondata = JSON.stringif
what i found in google, might help you.
$(document).ready(function() {
$("#sayHelloButton").click(function(event){
$.ajax({
type: "POST",
url: "dummyWebsevice.svc/HelloToYou",
data: "{'name': '" + $('#name').val() + "'}",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function(msg) {
AjaxSucceeded(msg);
},
error: AjaxFailed
});
});
});
function AjaxSucceeded(result) {
alert(result.d);
}
function AjaxFailed(result) {
alert(result.status + ' ' + result.statusText);
}
[WebMethod()]
public static string sayHello()
{
return "hello ";
}