function testAjax()
{
// 打开链接
xmlHttp.open("GET", "test.php", true);
// 服务器运行完后执行updatePage;
xmlHttp.onreadystatechange = updatePage;
xmlHttp.send(null);
}
// 处理服务器返回
function updatePage()
{
if(xmlHttp.readyState == 4)
{
var response = xmlHttp.responseText;
alert(response);
}
}
createXMLHttpRequest();test.php中的代码:
<?php
echo rand(0,100);//我用的是PHP5.XX,也加srand试过,没用。
?>我用上面代码为什么当我点击按键时显示的都是同一个数?
而我直接打开test.php刷新每次的数是随机变化的。
{
// 打开链接
xmlHttp.open("GET", "test.php", true);
// 服务器运行完后执行updatePage;
xmlHttp.onreadystatechange = updatePage;
xmlHttp.send(null);
}
// 处理服务器返回
function updatePage()
{
if(xmlHttp.readyState == 4)
{
var response = xmlHttp.responseText;
alert(response);
}
}
createXMLHttpRequest();test.php中的代码:
<?php
echo rand(0,100);//我用的是PHP5.XX,也加srand试过,没用。
?>我用上面代码为什么当我点击按键时显示的都是同一个数?
而我直接打开test.php刷新每次的数是随机变化的。
解决方案 »
- PHP程序怎么支持迅雷下载 迅雷保存的总是我写的PHP文件
- 大家看到了吗,动态语言(php)的前途!!
- uchome:mysql query error
- shtml和html生成哪种更好,更适后seo优化?
- 求一条SQL语句
- <param xxx name="src" xxx value="" xxx /> 当name和value位置不确定时,怎么写匹配正则?
- 我现在在做一个播放器,不知道怎么把音乐列表添加到mediaplayer中去
- 新手请教,redhatlinux9.0下如何配置PHP开发环境
- 怎么运行PHP要下载PHP文件?
- 为什么我的apache+php是下载???
- 用move_uploaded_file()上传文件出错
- 在线编辑器上传图片问题 请高手进!
xmlHttp.open("GET", "test.php?.r=" + Math.rand() , true);
我把text.php传来的数据设置为<div id="divAjax"></div>里面的内容.
document.getElementById("divAjax").innerText = unescape(response);结果网页上是正常显示了,但我查看源码(IE页面右击:查看源文件)却发现HTML源码中的<div id="divAjax"></div>
里面的内容并没有改变,这是怎么加事?
你查看到的源码是从服务器取回的html文件的内容你动态的添加修改是不会反映到这个文件中的。