erbsoftware
erbsoftware

Reputation: 365

why isn't my javascript function not being called

Working with MVC

view:

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

Javascript function:

   function getMembershipDetails(orderTemplateId, url) {
    $.ajax({
        type: "GET",
        url: url,
        data:{
            orderTemplateId: orderTemplateId
        },
        success: function (html) {
            //$("#search-structure-target").html(html);
            console.log(JSON.stringify(html))
        },
        error: function (err) {
            console.log(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?

Upvotes: 0

Views: 152

Answers (1)

Suren Srapyan
Suren Srapyan

Reputation: 68685

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.

Upvotes: 2

Related Questions