Here is the relevant View cshtml code
<tbody>
@foreach (var task in Model.TasksSummaryList)
{
<tr>
<th onclick="OnPatientSelected('@task.PatientID')">@task.PatientName</th>
<th>@task.Status</th>
<th>@task.TaskCount</th>
<th>@task.MostRecentTask</th>
</tr>
}
</tbody>
Here is the external javascript file containing OnPatientSelected
function OnPatientSelected(selectedPatientID) {
$.ajax({
type: "POST",
url: "TasksSummary/TaksSummaryDetailsView",
data: { selectedPatientID: selectedPatientID },
error: function () {
alert("fail");
},
success: function(){
alert("success");
}
});
}
This always shows success but never calls the Controller ActionMethod I want
[AllowAnonymous]
[HttpPost]
public ActionResult TasksSummaryDetailsView(/*data from view*/string selectedPatientID)
{
int i = 09;
//Received PatientID from View (Client)
//Browse to the appropriate view
return View();
}