+ -
当前位置:首页 → 问答吧 → jquery的Ajax的问题

jquery的Ajax的问题

时间:2011-03-03

来源:互联网

用jquery自带的Ajax里面去提交服务器A.aspx页面,A.asp.cs里面的代码是Response.Write("Test");
但是取得的Ajax的值是整个A.aspx页面的值,包括<html>........</html>,请问如何才能取得仅仅是Test的值?

作者: webhermit   发布时间: 2011-03-03

如果用ajax的话,的要用页面里面的static metod
然后返回类型可以是string,int,..
[System.Web.Services.WebMethod]
  public static string GetServerTime()
  {
  return DateTime.Now.ToString();
  }

作者: showenxxx   发布时间: 2011-03-03

一种方法是A.aspx里面除了输出Test,其它任何东西都去掉不要输出

一种方法是给Test前后加上特定标记,例如<div id="result">Test</div>;ajax得到后,查找<div id="result">的位置,取得Test

作者: hongmei85   发布时间: 2011-03-03

引用 1 楼 showenxxx 的回复:
如果用ajax的话,的要用页面里面的static metod
然后返回类型可以是string,int,..
[System.Web.Services.WebMethod]
public static string GetServerTime()
{
return DateTime.Now.ToString();
}

=======================
问下在使用Ajax页面,如何调用这个方法?如果仅仅是提交页面的话,返回的还是所有html页面的值

作者: webhermit   发布时间: 2011-03-03