开发者

why jquery can't return string/text?

default.aspx

<button id="getGrouper">GetGroupers</button>

 <script type="text/开发者_如何学Gojavascript">
        $(document).ready(function () {
            $("#getGrouper").click(function () {
                $.ajax({
                    type: "post",
                    url: "Groupers.aspx/groupers",
                    data: "{pid:25}",
                    dataType: "text",
                    success: function (data) { alert(data); },
                    error: function (err) { alert("err:" + err); }
                });
                return false;
            });
        });
    </script>

groupers.aspx.cs

[WebMethod]
public static string groupers(

    int project_id)
    { 

    string employees = "";

    foreach (string s in ids.Split(','))
                        {
                            u = user.getUserbyUid(Convert.ToInt32(s));

                            employees += "<a class=\"reply_notify_delete\" href =showuser.aspx?uid=" + u.Uid + "&pid=" + p.Pid + ">" + u.userName + "</a>  ";
                        }
    return employees;

    }

want to get groupers by a project_id

i want to get string type ,then append it, but i debug the code , it doesn't work , no response , and i set breakpoin , it doesn't go into "groupers" static Method , why ?


Where you have

"{pid:25}",
dataType: "text",

change it to

'{"project_id":25}',
dataType: "json", 
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜