ajax无闪刷新

来源:百度知道 编辑:UC知道 时间:2024/05/23 16:59:29
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>ajax无闪刷新</title>
<style type="text/css">
.ok{width:400px;height:100px;border:1px solid #000;}
</style>
</head>
<body onload="MyShow()"><!--浏览器打开的时候就开始执行了-->
<script language="JavaScript">
function GetResult() {
http_request = false;
if(window.XMLHttpRequest) {
http_request = new XMLHttpRequest();
if (http_request.ov

http_request.open("POST","1.txt",false); //获取的页面
http_request.send();

该为
http_request.open("POST","1.txt",true); //获取的页面
http_request.send(NULL);

另外应该先获取表格,再修改里面的内容:

tr = document.getElementsByName('tb').getElementsByTaget(tr);//获得某一行
td = tr.getElementsByTaget('tr');//该行的获得某个单元格

用for(i=0; i<tr.length;i++)
tr[i]//得到每一行
再嵌套for(i=0; i<td.length;i++) td[i]得到行的每一单元格
然后设置里面的innerHTML
注意用alert()输出一下你得到的单元格的值,看是否获取正确。