gpt4 book ai didi

jquery - 在 jquery MVC 4 中使用服务器端变量

转载 作者:行者123 更新时间:2023-12-01 04:09:53 25 4
gpt4 key购买 nike

我的 MVC4 应用程序中有一个服务器端全局变量。

现在我需要使用 j Query 在我的 View 中使用该变量。

谁能告诉我如何使用 j Query 在 View 中使用该变量。

变量

namespace Saif.Models
{
public class ClsGlobal
{
static string _AbsoluterUrl;
public static string AbsoluterUrl
{
get { return _AbsoluterUrl; }
set { _AbsoluterUrl = value; }
}
}
}

在J查询$(document).ready
var url = @Saif.Models.ClsGlobal.AbsoluterUrl;

最佳答案

尝试将 '' 添加到 JavaScript 中的网址:

var url = '@Saif.Models.ClsGlobal.AbsoluterUrl';

url 现在将包含 AbsoluteUrl 的值。

关于jquery - 在 jquery MVC 4 中使用服务器端变量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22216728/

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