views:

57

answers:

1

default.aspx

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

 <script type="text/javascript">
        $(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 ?

+1  A: 

Where you have

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

change it to

'{"project_id":25}',
dataType: "json", 
Mark Schultheiss
You don't need to match the c# parameter (project_id). You can name them whatever you like, as long as you use them in the right order.
Marko