AJAX学习笔记

放放Delphi,继续我的WEB编程

创建XMLHttpRequest对象的一个实例

function createXmlHttpRequestObject()
{
  var xmlHttp;
  if(window.ActiveXObject)
  {
    try
    {
      xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
    }
    catch (e)
    {
      xmlHttp = false;
    }
  }
  else
  {
    try
    {
      xmlHttp = new XMLHttpRequest();
    }
    catch (e)
    {
      xmlHttp = false;
    }
  }
  if (!xmlHttp)
    alert("Error creating the XMLHttpRequest object.");
  else
    return xmlHttp;
}
 $.ajax({

 type:"post",

 url:"stu_newpassPost.aspx",

 data:"pass="+document.form1.pass.value+"&t="+Math.random(),

 success:function(html){alert(html);}

 });
$.get("stu_delWork.aspx",{"user":"student","delid":id,"t":Math.random()},function(data){alert(data);}