Below is the View cshtml code that is relevant:
<tbody>
@foreach (var job in Model.JobsList)
{
<tr>
<th onclick="OnJobSelected('@job.JobID')">@job.JobTitle</th>
<th>@job.Status</th>
<th>@job.TaskCount</th>
<th>@job.MostRecentTask</th>
</tr>
}
</tbody>
Here is the external javascript file that contains the function OnJobSelected:
function OnJobSelected(selectedJobID) {
$.ajax({
type: "POST",
url: "JobsSummary/JobDetailsView",
data: { selectedJobID: selectedJobID },
error: function () {
alert("fail");
},
success: function(){
alert("success");
}
});
}
Despite always displaying success, this code doesn't call the desired Controller ActionMethod:
[AllowAnonymous]
[HttpPost]
public ActionResult JobDetailsView(/*data from view*/string selectedJobID)
{
int i = 09;
//Received JobID from View (Client)
//Navigate to the appropriate view
return View();
}