使用 XMLHttpRequest 对象

 

/* Create a new XMLHttpRequest object to talk to the Web server */
var xmlHttp = false;

/*@cc_on @*/
/*@if (@_jscript_version >= 5)

try {
  xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
  try {
    xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
  } catch (e2) {
    xmlHttp = false;
  }
}
@end @*/

if (!xmlHttp && typeof XMLHttpRequest != 'undefined') {
  xmlHttp 
= new XMLHttpRequest();
}


function callServer() {
  
// Build the URL to connect to
  var url = "/test.aspx?id=" + escape(id) + "&name=" + escape(name);

  
// Open a connection to the server
  xmlHttp.open("GET", url, true);

  
// Setup a function for the server to run when it's done
  xmlHttp.onreadystatechange = updatePage;

  
// Send the request
  xmlHttp.send(null);
}


function updatePage() {
  
if (xmlHttp.readyState == 4) {
    
var response = xmlHttp.responseText;
  }
}
posted @ 2006-08-04 15:20 dannyr|一个都不能少! 阅读(176) 评论(0)  编辑 收藏 所属分类: 杂项

标题  
姓名  
主页
Email (只有博主才能看到) 
验证码 *  看不清,换一张 [登录][注册]
内容(请不要发表任何与政治相关的内容)  
  登录  使用高级评论  新用户注册  返回页首  恢复上次提交      
该文被作者在 2006-08-05 08:00 编辑过


相关链接: