62,074
社区成员
发帖
与我相关
我的任务
分享
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script src="jquery-1.4.4.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function () {
$("#Button1").click(function () {
$.ajax({
type: "POST",
url: "AJAX.aspx/GetStr",
data: "{'str':'我是','str2':'XXX'}",
dataType: "json",
contentType: "application/json; charset=utf-8",
success: function (data) {
alert(data.d);
},
error: function (err) {
alert(err);
}
});
});
});
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<input id="Button1" type="button" value="button" />
</div>
</form>
</body>
</html>
[WebMethod]
public static string GetStr(string str, string str2)
{
return str + str2;
}
[WebMethod] public static string GetStr(string str, string str2) { return str + str2; }
[WebMethod]
public static List<string> GetArray()
{
List<string> li = new List<string>();
for (int i = 0; i < 10; i++)
li.Add(i + "");
return li;
}