【发布时间】:2014-01-08 08:06:07
【问题描述】:
text.ascx 代码:
<script type = "text/javascript">
function ShowCurrentTime() {
$.ajax({
type: "POST",
url: "TestAjax.aspx/GetCurrentTime",
data: '{}',
contentType: "application/json; charset=utf-8",
dataType: "json",
success: OnSuccess,
failure: function (response) {
alert(response.d);
}
});
}
function OnSuccess(response) {
alert(response.d);
}
<input type="checkbox" id='chkl' onclick=ShowCurrentTime();>';
text.ascx.cs 代码:
[System.Web.Services.WebMethod]
public static string GetCurrentTime(string name)
{
return "Hello " + name + Environment.NewLine + "The Current Time is: "
+ DateTime.Now.ToString();
}
如何在用户控件中调用jquery ajax。
【问题讨论】: