传统ajax Code 复制代码 代码如下: <BR>var xmlHttp; <BR>function createXMLHttpRequest(){ <BR>if(window.ActiveXObject) <BR>xmlHttp = new ActiveXObject("Microsoft.XMLHTTP"); <BR>else if(window.XMLHttpRequest) <BR>xmlHttp = new XMLHttpRequest(); <BR>} <BR>function startRequest(){ <BR>createXMLHttpRequest(); <BR>xmlHttp.open("GET","14-1.aspx",true); <BR>xmlHttp.onreadystatechange = function(){ <BR>if(xmlHttp.readyState == 4 && xmlHttp.status == 200) <BR>document.getElementById("target").innerHTML = xmlHttp.responseText; <BR>} <BR>xmlHttp.send(null); <BR>} <BR> JQuery方法 Code 复制代码 代码如下: <BR>function startRequest(){ <BR>$("#target").load("14-1.aspx"); <BR>} <BR> get and post Code 复制代码 代码如下: GET VS. POST <BR>function createQueryString(){ <BR>var firstName = encodeURI($("#firstName").val()); <BR>var birthday = encodeURI($("#birthday").val()); <BR>//组合成对象的形式 <BR>var queryString = {firstName:firstName,birthday:birthday}; <BR>return queryString; <BR>} <BR>function doRequestUsingGET(){ <BR>$.get("14-5.aspx",createQueryString(), <BR>//发送GET请求 <BR>function(data){ <BR>$("#serverResponse").html(decodeURI(data)); <BR>} <BR>); <BR>} <BR>function doRequestUsingPOST(){ <BR>$.post("14-5.aspx",createQueryString(), <BR>//发送POST请求 <BR>function(data){ <BR>$("#serverResponse").html(decodeURI(data)); <BR>} <BR>); <BR>} <BR> 输入姓名和生日