ajax调用问题
ajax调用失败。高手帮忙看看。
页面中。
<script language="javascript" type="text/javascript">
var g_tbName = null;
var g_lbMessage = null;
function pageLoad()
{
g_tbName = new Sys.Preview.UI.TextBox($get('tbName'));
g_tbName.initialize();
g_lbMessage = new Sys.Preview.UI.Label($get('lbMessage'));
g_lbMessage.initialize();
}
function cb_getServerHelloString(result)
{
g_lbMessage.set_text(result);
}
function sayHello(){
var name = g_tbName.get_text();
PageMethod.sayHello(name, cb_getServerHelloString);
}
</script>
.cs文件中
[System.Web.Services.WebMethod]
public static string sayHello(string name)
{
return string.Format("Hello From PageMethods.sayHello() : {0}, now it is {1}",name,DateTime.Now);
}
------解决方案--------------------protected void Page_Load(object sender, EventArgs e)
{
ServiceReference sr = new ServiceReference();
sr.Path = "../WebService/AjaxMethod.asmx";
ScriptManager1.Services.Add(sr);
}
是不是没加上面这段代码?
------解决方案--------------------
如需要阅读该回复,请登录或注册CSDN!