试图从 JSON 调用 C# 类。
JSON 代码在我的 master.cshtml 文件中,如下所示:
var tips = $(".validateTips");
function updateTips(t) {
tips
.text(t)
setTimeout(function () {
tips.removeClass("ui-state-highlight", 1500);
}, 500);
}
$.ajax({
type: "POST",
url: "/App_Code/LoginClass.cs/test",
data: {},
contentType: "application/json; charset=utf-8",
datatype: "JSON",
success: function (msg) {
updateTips(msg.d);
}
});
C# 代码位于 LoginClass.cs 文件中,如下所示:
public class LoginClass
{
public static string test()
{
return "hello";
}
}
my solution folders looks like this:
+----App_Code
| |
| +---LoginClass.cs
|
+----Views
| |
| +---Shared
| |
| +---Master.cshtml
|
+----default.cshtml (Where the master layout page is connected to)
更新提示没有