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
  • make the employees variable a System.Text.StringBuilder if this is more than test code... Commented Jul 4, 2010 at 0:53

1 Answer 1

1

Where you have

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

change it to

'{"project_id":25}',
dataType: "json", 
Sign up to request clarification or add additional context in comments.

1 Comment

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.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.