Recently delving into the world of MVC, I've been scouring for answers as to why this particular piece of code isn't functioning as intended.
Below is the snippet from my View:
$(function() {
$("#ddlNumberOfRecords").change(function() {
var numberOfRecords = $("#ddlNumberOfRecords").val();
$.ajax({
type: "POST",
url: '@Url.Action("NumberOfRecordsChanged")',
data: { numberOfRecords: numberOfRecords },
success: function(returndata) {
if (!returndata.ok) {
window.alert(' error : ' + returndata.message);
} else {
$('#Grid').html(returndata);
}
}
});
});
});
@Html.DropDownList("ddlNumberOfRecords", Model.NumberOfRecordsSelectList)
I'm at a loss here. Can someone shed some light on what might be causing this issue? Additionally, are there any effective ways to debug this JavaScript code? I tried setting breakpoints, but they never seem to trigger.
EDIT: Below is the Action method I've created. It's quite barebones at the moment as I am solely focused on resolving the problem with the functionality. However, even with breakpoints set, it doesn't seem to be hitting the designated point.
[HttpPost]
public ActionResult NumberOfRecordsChanged(int numberOfRecords)
{
return null;
}