jQueryAjax中的Url.Action:未传递第二个参数

jQueryAjax中的Url.Action:未传递第二个参数,jquery,ajax,razor,url.action,Jquery,Ajax,Razor,Url.action,我试图用jQueryAjax在Url.Action函数中传递两个参数,只传递第一个参数。调试时,这两个参数在ajax函数中正确显示。在数据中传递的值传递正确 我做错了什么 以下是视图中的代码: <script type="text/javascript"> $(function () { $("#sendForm").click(function () { //they both show correctly in the conso

我试图用jQueryAjax在
Url.Action
函数中传递两个参数,只传递第一个参数。调试时,这两个参数在ajax函数中正确显示。在
数据
中传递的值传递正确

我做错了什么

以下是视图中的代码:

<script type="text/javascript">

    $(function () {
        $("#sendForm").click(function () {
            //they both show correctly in the console
            console.log('@ViewData["recordURL"]');
            console.log('@ViewData["title"]');
            $.ajax({
                url: '@Url.Action("SendEmail", "Search", new { title = ViewData["title"], recordURL = ViewData["recordURL"] })',
                type: "POST",
                data: {
                    //placed these here so don't have to intersperse javascript with razor code in Url.Action
                    recepient: $("#recepient").val(),
                    message: $("#message").val()
                },
                success: function (result) {
                    $(".emailForm").hide();
                    $(".results").text(result);

                    window.setTimeout(closeEmailPopup, 3500);
                }
            });
        });
    });
</script>

我想问题在于你的最终URL字符串。尝试将其包装为Html.Raw以防止转义符号(&S):

...
url: '@Html.Raw(Url.Action("SendEmail", "Search", new { title = ViewData["title"], recordURL = ViewData["recordURL"] }))',
...
摘自此

...
url: '@Html.Raw(Url.Action("SendEmail", "Search", new { title = ViewData["title"], recordURL = ViewData["recordURL"] }))',
...