62,074
社区成员
发帖
与我相关
我的任务
分享
namespace WebApplication2.TestWebMethod
{
public partial class WebForm2 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
[WebMethod]
public static string TestWebMethod01()
{
return "Hello Ajax";
//return JsonConvert.SerializeObject(new
//{ Success = true, Data = "hello", Msg = "获取成功" });
}
}
}
<script type="text/javascript">
$(document).ready(function () {
$("#but01").click(function () {
$.ajax({
type: "post",
url: "WebForm2.aspx/TestWebMethod01",
contentType: "application/json",
data: "{}",
dataType: "json",
success: function (data) {
alert(data.d+" +js+");
},
error: function (err) {
alert("webForm方法错误!");
}
});
});
});
</script>
// settings.AutoRedirectMode = RedirectMode.Permanent;
原帖http://www.it1352.com/59318.html