-1

Url.Action parameter name as a function parameter. Here i use actionNameParameter as a function parameter now how i write this parameter on url: '@Url.Action(actionNameParameter)' I tried this code but it does not work. But i write like url:'@Url.Action("StringactionName")' then it works. But i need to use the function parameter as @Url.Action(actionNameParameter)

function example(actionNameParameter) {
        $.ajax({
            type: 'POST',
            url: '@Url.Action(actionNameParameter)'
        });
    }
nazmul.3026
  • 918
  • 1
  • 9
  • 20
  • `@Url.Action()` is razor (server side) code - it is executed on the server before the html is sent to the browser. You `actionNameParameter` is a javascript (client side) variable and does not even exist on the server - its not in scope –  Oct 07 '18 at 05:44

1 Answers1

0

hi can use escape sequence for single code 

 var actionNameParameter = "\'" + "@Url.Action(actionNameParameter)" + "\'";
LDS
  • 354
  • 3
  • 9