Below is an Ajax call I make to a controller whenever a user clicks on a certain icon on my ASP MVC3 View. It is supposed to call a method in the controller by the name ofPopDetails, however after setting a breakpoint in the controller I can see this is not happening. I tried using both URLs listed below, however neither has worked. Since this is the first time I've used Ajax, I'm not really sure what's going on. Any ideas or suggestions would be greatly appreciated!
Ajax code from View:
<script src="@Url.Content("~/Scripts/jquery.unobtrusive-ajax.js")" type="text/javascript"></script>
<script type="text/javascript">
function GetProgramDetails(pgmname) {
var request = $.ajax({
type: 'POST',
url: '~/BatchProgramsContoller/PopDetails',
//url: '~/BatchProgramsContoller/PopDetails',
data: { programName: pgmname },
dataType: 'html'
});
request.done(function (data) {
$('#programExplanation').html(data);
});
}
</script>
Method from BatchProgramsController:
[HttpPost]
public string PopDetails(string programName)
{
BatchPrograms batchprograms = db.BatchPrograms.Find(programName);
if (batchprograms == null) return string.Empty;
StringBuilder s = new StringBuilder();
s.Append(batchprograms.ProgramName + " - " + batchprograms.ShortDescription);
s.Append("<br />Job Names: " + batchprograms.PrdJobName + ", " + batchprograms.QuaJobName );
s.Append("<br /> " + batchprograms.Description);
return s.ToString();
}