Sending objects to ASP.NET from JSON works fine if you have a class built that matches the JSON object, but all I need to do is send a single integer.
var request = { "int": jQuery('select#propSelect').val() }
jQuery.ajax({
url: '/Property/getPropByID',
type: 'POST',
data: JSON.stringify(request),
dataType: 'json',
contentType: 'application/json',
success: on_request_success,
error: on_request_error
});
Does anybody know how to do this?
Once it gets to the server I try to print out what has been passed and it displays nothing.
public void getPropByID(string objects)
{
System.Diagnostics.Debug.WriteLine("JSON> "+ objects);
//return js.Serialize(db.Properties.Find(id));
}
If all you need to do is send an int, then do this:
And on the web service side:
Note: I believe the parameter name on your web service must match the parameter name on the client side.