当前位置: 代码迷 >> ASP.NET >> 大家看看小弟我这个简单的ajax
  详细解决方案

大家看看小弟我这个简单的ajax

热度:7637   发布时间:2013-02-25 00:00:00.0
大家看看我这个简单的ajax
var   XmlHttp=new   ActiveXObject( "Microsoft.XMLHTTP ");
              function   sendAJAX()
              {
                      XmlHttp.Open( "POST ", "testajax.aspx ",true);
                      XmlHttp.send(null);
                      XmlHttp.onreadystatechange=ServerProcess;
              }
              function   ServerProcess()
              {
                      if(XmlHttp.readystate==4)
                      {
                            if(XmlHttp.status==200)
                            {
                                    alert(XmlHttp.responsetext);
                            }
                      }
              }

=====================testajax.aspx.cs
Response.Write( "123 ");

1.弹出窗里不光是123而是一个页面为什么?
2.用asp.net   ajax应该怎么做?



------解决方案--------------------------------------------------------
XmlHttp.Open( "POST ", "testajax.aspx ",true);
XmlHttp.send(null);
----------------------------
如果是用POST的话,是不能send(null)的只有
XmlHttp.Open( "GET ", "testajax.aspx ",true);
才能send(null)


------解决方案--------------------------------------------------------
=====================testajax.aspx.cs
Response.Write( "123 ");
Response.End();


------解决方案--------------------------------------------------------
是啊
总之最后一定是一个Response.End();

------解决方案--------------------------------------------------------
Response.Write( "123 ");
Response.End();
  相关解决方案