Posting from JQuery to WCF Service
- by Villager
Hello,
I have a WCF Service (called "myservice.svc") that takes a message from a user and saves it to the database. It returns a response to the user in the form of a number. This operation looks like this:
[OperationContract]
[WebGet]
public string SubmitMessage(string message)
{
try
{
// SAVE TO DATABASE
return "1";
}
catch (Exception ex)
{
return "0";
}
}
I want to call this operation from some JQuery. I'm using the approach shown here:
$.getJSON(
"/services/myService.svc",
{message:"some text"},
function (data) {
alert("success");
}
);
Oddly, the "success" alert is never displayed. In addition, I have set a breakpoint in my WCF service and it is never being tripped. What am I doing wrong?
Thank you