1、 web.config配置如下:
<system.web>
<httpHandlers>
<add verb="POST,GET" path="ajaxpro/*.ashx" type="AjaxPro.AjaxHandlerFactory,AjaxPro.2"/>
</httpHandlers>
</system.web>
2、添加引用AjaxPro.2.dll
3、后台代码如下
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using AjaxPro;
namespace used_car
{
public partial class WebForm1 : System.Web.UI.Page
{
protected void Page_Load(object sender,EventArgs e)
{
AjaxPro.Utility.RegisterTypeForAjax(typeof(WebForm1),this.Page);
}
[AjaxPro.AjaxMethod]
public string GetServerTime()
{
return DateTime.Now.ToString();
}
}
}
4、前台调用:如下
<script language="javascript" type="text/javascript">
function testF() {
var dt = used_car.WebForm1.GetServerTime().value;
alert(dt);
}
</script>
<input id="comit" type="button" value="Ok" onclick="testF()" />
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。