0

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?

4
  • escape string in you html. Commented Oct 10, 2016 at 14:35
  • 2
    onlick mistyped? Commented Oct 10, 2016 at 14:35
  • 1
    onlick should ob onclick Commented Oct 10, 2016 at 14:36
  • FFS!! thanks @emil and caramiriel I didn't notice Commented Oct 10, 2016 at 14:37

1 Answer 1

2

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.