我试图使用ajax创建一个进度条,这里是html代码:
<BODY onload='process();move()'>
<div id='myProgress'>
<div id='progress-bar'>
</div>
</div>
<br><p> progress bar <A id='percent'></A></p><br>
STATUS = <A id='runtime'></A>
</BODY>
这里是ajax代码:
function handleServerResponse()
{
if(xmlHttp.readyState==4 && xmlHttp.status==200)
{
xmlResponse=xmlHttp.responseXML;
xmldoc = xmlResponse.getElementsByTagName('response');
message = xmldoc[0].firstChild.nodeValue;
document.getElementById('runtime').innerHTML=message;
}
}
这是进度条的javascript代码:
function move()
{
elem = document.getElementById('progress-bar');
width = message;
elem.style.width = width + '%';
document.getElementById('percent').innerHTML = width;
}
我无法在javascript中访问'message'变量 帮助