Metrics
0
Watch 9 Star 23 Fork 5

Mines / Mines.AjaxC#Apache-2.0

Sign up for free
Explore and code with more than 2 million developers,Free private repositories !:)
Sign up
.net的动态代理组件,适用于.net framework 4.0及以上版本,方便通过js直接调用后端指定的方法 spread retract

Clone or download
Cancel
Notice: Creating folder will generate an empty file .keep, because not support in Git
Loading...
README.md

#Mines.Ajax 实现用javascript动态调用后端方法的js代理类,前端需要jquery的支持,后端需要引用json.net

前端js引用示例:

<script type="text/javascript" src="() %>"></script>

Js调用示例

        $(".submit1").click(function () {
            var input1 = $(".name").val();
            GetFun.Welcome(input1, function (res) {
                if (res && res.value) {
                    $(".res").html(res.value);
                }
            })
        })

后端C#代码

namespace Mines.Ajax.Test { [Mines.Ajax.AjaxClass] public class GetFun { [Mines.Ajax.AjaxMethod] public int Sum(int[] arr) { int sum = 0; foreach (var item in arr) { sum += item; } return sum; } [Mines.Ajax.AjaxMethod(Mines.Ajax.SessionState.ReadAndWrite)] public string Welcome(string youname) { var oldname = System.Web.HttpContext.Current.Session["name"] as string; if (oldname != null) oldname = "上一位访问者是:" + oldname + "
"; System.Web.HttpContext.Current.Session["name"] = youname; return oldname + youname + ",您好!欢迎使用Mines.Ajax… 现在时间:" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); } }

js调用结果: js调用结果

Comments ( 5 )

You need to Sign in for post a comment

C#
1
https://gitee.com/leiweicyz/Mines.Ajax.git
git@gitee.com:leiweicyz/Mines.Ajax.git

Help Search