.JS File using @url.action in Ajax Url

后端 未结 3 1229
粉色の甜心
粉色の甜心 2020-12-04 03:45

I been trying to use @Url.Action inside Ajax url in another external .JS file but unfortunately i got no luck.

Here\'s my Cod

3条回答
  •  渐次进展
    2020-12-04 04:01

    You can create a partial view, then inside this view are just list of hidden fields such as

    @Html.Hidden("ActionName", @Url.Action("ActionName", "Controller"))
    

    which generates this

    
    

    then you can call it like

      var urlAction = $('#ActioName').val();
    

    or you can create a js function like what I did

     function ActionCaller(actionName)
     {
        return $('#' + actionName).val();
     }
    
     var action = ActionCaller(ActionName);
    

提交回复
热议问题