I am a little fixated on the fact that probably the usual situation, but can not find many solutions.
I pass one int parameter to the MVC controller method, awaiting a Json response. The problem is that the parameter, being filled on the client side, is not recognized on the server and is interpreted as zero.
Here is the code:
function getBatches(p) {
$.ajax({
type: "GET",
data: "{'ProjectID': " + p + "}",
url: "/Home/Batches",
success: function(msg) {
populateBatches(msg);
}
});
}
The value for p is an integer. On the server side, the code is as follows:
[AcceptVerbs(HttpVerbs.Get)]
public JsonResult Batches(int ProjectID)
{
return Json(TimeHelper.GetBatchesForProject(ProjectID));
}
I tried changing it a bit so that the server side int argument was null (i.e. int? ProjectID), but again, that doesn't help. The problem is the translation. Ideas?
source
share