i have this in my partial view:
<script type="text/javascript">
var jqxhr = $.getJSON("<%= Url.Action("GetTrainingModulePoints" , "Home") %>", function (data) {
console.log(data.id);
});
</script>
HomeController:
[HttpGet]
public JsonResult GetTrainingModulePoints()
{
var currentUser = ZincService.GetUserForId(CurrentUser.UserId);
ZincService.TrainingService.GetTrainingModulePoints(currentUser.UserId);
return Json(new { success = true }, JsonRequestBehavior.AllowGet);
}
the GetTrainingModulePoints method is in the HomeController in the root controller directory.
I get an 500 Internal Server Error, so it is not finding it. What is wrong with my Url.Action?
please help?
thanks
You are correctly using an Url helper to generate the url to the controller action. But you are confusing status code 500 with 404. Status code 500 means Internal Server error. This error could be caused for example if an exception is thrown inside your controller action.
The
ZincService.GetUserForIdandZincService.TrainingService.GetTrainingModulePointsare good candidates for this exception.If you use a javascript debugging tool in your browser (such as FireBug or Chrome developer toolbar) you can inspect the Network tab where you will see the exact request/response for the AJAX request. By looking at the response you might get more information about the reason for the error.