gpt4 book ai didi

javascript - asp.net mvc 将参数从 Jquery ajax 调用传递到 Controller

转载 作者:行者123 更新时间:2023-12-03 06:53:48 24 4
gpt4 key购买 nike

我正在从 jquery 调用 Controller ,并尝试为其提供参数。我运气不好。当网址只是 /SurveySection/EditLocalization 时,它在没有参数的情况下工作正常,它不应该像这样 /SurveySection/EditLocalization?surveySectionId=3?localizationId=dfasdfas

jquery

   LinkAjax.ajaxRequest("/SurveySection/EditLocalization" += "?surveySectionId=" + "3" + "?languageId=" + $localizationList.val(),
"random data",
"localizationPartial",
null,
null,
localizationSelectList.renderLocalizationPartialView);

这就是我的 Controller 的样子

        public PartialViewResult EditLocalization(int surveySectionId, string languageId)
{
... ajax call fails because I can't pass in parameters correctly
}

最佳答案

也许 Controller 的 URL 是错误的。在基本 url 之后,查询字符串参数除以 ?,参数除以 &。试试这个:

LinkAjax.ajaxRequest("/SurveySection/EditLocalization" += "?surveySectionId=" + "3" + "&languageId=" + $localizationList.val(),
"random data",
"localizationPartial",
null,
null,
localizationSelectList.renderLocalizationPartialView);

关于javascript - asp.net mvc 将参数从 Jquery ajax 调用传递到 Controller ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37381013/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com