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;
}
希望通过project_id
获得石斑鱼我想得到字符串类型,然后追加它,但我调试代码,它不起作用,没有响应,我设置breakpoin,它没有进入“groupers”静态方法,为什么?
答案 0 :(得分:1)
你在哪里
"{pid:25}",
dataType: "text",
将其更改为
'{"project_id":25}',
dataType: "json",