小编mkt*_*two的帖子

在ASP.NET中通过jQuery/ajax获取复杂对象

这里是我的情况:我有一个UserBadge对象在ASP.NET中,它包含3个字段,作为一个User对象,Badge对象和boolean(isNotified),以检查用户是否已经通知赚取徽章.我在发送一个特定的问题,UserBadge从这个WebMethod():

[WebMethod()]
    public static UserBadge Notify()
    {
        var db = new achievDb();

        foreach (var uB in db.UserBadges)
        {
            if (System.Web.HttpContext.Current.User.Identity.Name == uB.User.UserName)
            {
                if (!uB.isNotified)
                {
                    return uB;
                }
            }
        }
        return null;
    }
Run Code Online (Sandbox Code Playgroud)

对我的$.ajax:

<script type="text/javascript">
            $(document).ready(function () {
                $.ajax({
                    type: "POST",
                    url: "../NotifCodeBehind.aspx/Notify",
                    data: "{}",
                    complete: function (result) {
                        if (result) {
                            $("#notify").jGrowl("You've unlocked a badge!", { header: 'Yay', close: function () {
                                $.ajax({ …
Run Code Online (Sandbox Code Playgroud)

c# asp.net ajax jquery json

5
推荐指数
2
解决办法
5368
查看次数

标签 统计

ajax ×1

asp.net ×1

c# ×1

jquery ×1

json ×1