我用的是VS2003 使用AJAX老出错 提示aspx页面的ajaxuse未定义,相关代码如下:
public class ajaxuse : System.Web.UI.Page
{
private void Page_Load(object sender, System.EventArgs e)
{
// 在此处放置用户代码以初始化页面
AjaxPro.Utility.RegisterTypeForAjax(typeof(ajaxuse));
}
[AjaxPro.AjaxMethod()] //申明是ajaxPro方法
public string GetServerTime()
{
System.Threading.Thread.Sleep(2000);
return DateTime.Now.ToString();
}
} <script type="text/javascript">
// loading效果
AjaxPro.onLoading = function(b)
{
var a = document.getElementById("loadinfo");
a.style.visibility = b ? "visible" : "hidden";
} function GetTime()
{
// 调用服务端方法
//调用方法:类名.方法名 (参数为指定一个回调函数)
ajaxuse.GetServerTime(callback);
} function callback(res) //回调函数,显示结果
{
alert(res.value);
}
</script>
public class ajaxuse : System.Web.UI.Page
{
private void Page_Load(object sender, System.EventArgs e)
{
// 在此处放置用户代码以初始化页面
AjaxPro.Utility.RegisterTypeForAjax(typeof(ajaxuse));
}
[AjaxPro.AjaxMethod()] //申明是ajaxPro方法
public string GetServerTime()
{
System.Threading.Thread.Sleep(2000);
return DateTime.Now.ToString();
}
} <script type="text/javascript">
// loading效果
AjaxPro.onLoading = function(b)
{
var a = document.getElementById("loadinfo");
a.style.visibility = b ? "visible" : "hidden";
} function GetTime()
{
// 调用服务端方法
//调用方法:类名.方法名 (参数为指定一个回调函数)
ajaxuse.GetServerTime(callback);
} function callback(res) //回调函数,显示结果
{
alert(res.value);
}
</script>
还的注意一个问题
AjaxPro.Utility.RegisterTypeForAjax(typeof(lianxi.ajax.ajaxuse));
lianxi.ajax.ajaxuse.GetServerTime(callback);
这里要把命名空间加上
相关页面如下:
http://topic.csdn.net/u/20071008/10/6ccaaabb-2748-4dd4-bffc-2c56cc744efd.html