是否将actionlink生成的url传递给javascript方法?

是否将actionlink生成的url传递给javascript方法?,javascript,asp.net-mvc-5,Javascript,Asp.net Mvc 5,我想将通过Html.ActionLink生成的url传递给javascript函数参数。那么,我该怎么做呢 提前感谢,您可以使用Url。操作帮助程序: <script type="text/javascript"> var url = '@Url.Action("Foo", "Bar")'; someJavascriptfunction(url); </script> 要在javascript文件中进行AJAXify的: $('a').click(fun

我想将通过Html.ActionLink生成的url传递给javascript函数参数。那么,我该怎么做呢


提前感谢,

您可以使用
Url。操作
帮助程序:

<script type="text/javascript">
    var url = '@Url.Action("Foo", "Bar")';
    someJavascriptfunction(url);
</script>
要在javascript文件中进行AJAXify的:

$('a').click(function() {
    $.ajax({
        url: this.href,
        type: 'GET',
        cache: false,
        success: function(result) {
            // Do something with the result of the AJAX call
        }
    });
    return false;
});
$('a').click(function() {
    $.ajax({
        url: this.href,
        type: 'GET',
        cache: false,
        success: function(result) {
            // Do something with the result of the AJAX call
        }
    });
    return false;
});