Hi,
I have written a simple HTML page where I am passing JSON object to WCF service. When I run the service in debug mode (VS2012) and call the page from IE 10, Debugger gets called but in a parameter place object passed is null..
jQuery Code:
var objJSON = {
"postJSON": {
"id": "0",
"emp_name": "abc",
"emp_city": "delhi",
"emp_addr": "india"
}
};
$.ajax({
type: "POST",
url: "http://localhost:8080/MainService.svc/updatedata",
data: JSON.stringify(objJSON),
dataType: "json",
contentType: "application/json; charset=utf-8",
processData:true,
success: function (objSuccess) {
console.log("success");
console.log(JSON.stringify(objSuccess));
}
,
error: function (objError) {
console.log("error");
alert(JSON.stringify(objError));
}
});
WCF Service Code:
MainService.svc.cs
public ClsEmployee UpdateEmployee(ClsEmployee objEmployee)
{
new ClsTransaction().updateRecord(objEmployee);
Service Contract
[OperationContract]
[WebInvoke(Method = "POST",
ResponseFormat = WebMessageFormat.Json,
RequestFormat = WebMessageFormat.Json,
BodyStyle = WebMessageBodyStyle.Wrapped,
UriTemplate = "updatedata")]
ClsEmployee UpdateEmployee(ClsEmployee postJSON);
}