首 页 ASP ASP.NET PHP JSP Ajax DIV+CSS JavaScript XML C#
MySQL MSSQL Access Oracle Linux Server 电脑技巧 网络安全 建站经验 其它

使用AjaxPro实现Ajax效果

整理日期:2007年08月11日 【字体:


伊图教程网[www.etoow.com]
http://www.etoow.com/html/2007-08/1186821583.html
      //调用方法:类名.方法名 (参数为指定一个回调函数)
      myLoad.GetServerTime(callback);
    }

    function callback(res) //回调函数,显示结果
    {
      alert(res.value);
    }
    </script>
  </form>
</body>
</html>
注:javascript代码放在form内结束处,确保可以访问AjaxPro对象,否则提示AjaxPro未定义;因为在服务端page_load输出js到页面后才到找到AjaxPro对象;且javascript的defer="defer",页面加载时先不执行此代码。
服务端代码:
public partial class myLoad : System.Web.UI.Page
{
  protected void Page_Load(object sender, EventArgs e)
  {
    AjaxPro.Utility.RegisterTypeForAjax(typeof(myLoad)); //注册ajaxPro,括号中的参数是当前的类名
  }

  [AjaxPro.AjaxMethod] //申明是ajaxPro方法
  public string GetServerTime()
  {
    System.Threading.Thread.Sleep(2000);
    return DateTime.Now.ToString();
  }
}
Tags:
使用AjaxPro实现Ajax效果
'http://www.etoow.com/html/2007-08/1186821583.html
1
 
信息搜索
  
联系我们关于本站广告服务设为首页 收藏本站友情链接网站地图
Copyright © Etoow.com Inc. All Rights Reserved