Jon
Jon

Reputation: 40032

Pass a client side variable to @Url.Action in jQuery function

This is my code below and I am trying to pass the ID variable Url.Action method

I can't work out how to do it.

Thanks

function onRowSelected(e) {
       var ID = e.row.cells[0].innerHTML;

        $.get('@Url.Action("GetTestStepByID","AlternativeTest", new { id = ID } )', function (data) {
            $('#accordion').replaceWith(data);
        }); 
    }

Upvotes: 3

Views: 6857

Answers (1)

JAS
JAS

Reputation: 294

You can try this

function onRowSelected(e) {
   var ID = e.row.cells[0].innerHTML;

    $.get('@Url.Action("GetTestStepByID","AlternativeTest")' + '/' + ID, function (data) {
        $('#accordion').replaceWith(data);
    }); 
}

Upvotes: 5

Related Questions