erbsoftware erbsoftware - 5 months ago 23
Javascript Question

why isn't my javascript function not being called

Working with MVC


<a onlick="getMembershipDetails('@memberships.OrderTemplateId', '@Url.Action("GetMembershipContractDetails","MembersA")');" class="cw-grid-link">Details</a><br/>

Javascript function:

function getMembershipDetails(orderTemplateId, url) {
type: "GET",
url: url,
orderTemplateId: orderTemplateId
success: function (html) {
error: function (err) {
traditional: true

Controller method which should be called:

public ActionResult GetMembershipContractDetails(string orderTemplateId)
if (String.IsNullOrEmpty(orderTemplateId))
return null;
var details = userOrganisationProvider.GetOrgFinSupportDetail(SelectedOrganisation, orderTemplateId);

return Json(details, JsonRequestBehavior.AllowGet);

For some reason my javascript function above is not being called. All the other similar functions work/get called except this one. What am I doing wrong?


You called another function and have another one.

See: you call getMembershipDetails but the name of your function is GetOrderFinancialDetails

<a onclick="GetOrderFinancialDetails('@memberships.OrderTemplateId', '@Url.Action("GetMembershipContractDetails","MembersA")');" class="cw-grid-link">Details</a><br/>

EDITED: As has been said in the comments, change onlick to onclick.