I'm trying to call a WCF web service hosted by IIS using jQuery. I can call it fine without any parameters, and I can also call it fine with a GET request that includes my parameter, but as soon as I try to send in the request via POST, the call is failing.
The web service is currently nothing but:
[OperationContract, WebInvoke]
public ValidationResultSummary TestValidateOn(
object day)
{
return null;
}
I've set the parameter to object, to make sure the issue isn't something with type coercion. With a breakpoint in the web service, I know the call without parameters as well as the GET call with param succeeds; in the latter the expected value is sent up.
Calling code looks like:
$.ajax({
// type: "GET",
// url: "../Shared/Services/DomainServices.svc/TestValidateOn?day='12/Jan/2010'",
type: "POST",
url: "../Shared/Services/DomainServices.svc/TestValidateOn",
// data: "{ }", --This works if object type param, calls with null
data: "{'day': " + selectedDate + "}", // This fails miserably
// data: "{'day': '" + selectedDate + "'}", --This also fails miserably
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function(data) {
displayResults(data.d);
},
error: function(xmlHttpReq, status, errThrown) {
displayError(xmlHttpReq, status, errThrown);
}
});
The POST call never reaches my breakpoint, and on the client, error 500 - "Internal Server Error" - is returned.
Any help would be appreciated.