Hi I have the following code
In JQuery:
this.myFunction = function()
{
var dto =
{
id : getID()
};
//alert(getID();) to verify that my number is indeed non zero.
$.ajax({
type: "POST",
url: "Create",
contentType: 'application/json; charset=utf-8',
data: JSON.stringify(dto),
dataType: "json",
success: function(result) {
alert("Data Returned: ");
}
});
}
in C#
public void myCFunction(int i)
{
//do some stuff
}
When I ran the debugger in Visual Studios, I noticed that the integer in my C# function is always zero despite that the value I pass it is not zero.
JSON.stringify(dto),should maybe beJSON.stringify(dataPost)?JSON.stringify(dto)translatesdtoto{"id":12345}.