【发布时间】:2013-02-28 21:13:29
【问题描述】:
当我单击记录按钮时,我有以下脚本开始运行。 我想在单击记录按钮时显示图像,这与我们上传图像时通常显示的相同... 这是脚本:
<script>
function st()
{
if (window.XMLHttpRequest)
{
xmlhttp=new XMLHttpRequest();
}
else
{
xmlhttp=new ActiveXObject('Microsoft.XMLHTTP');
}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
alert('RECORDING Start');
}
}
xmlhttp.open('GET','http://localhost/IPCAM/start.php;)
xmlhttp.send();
setTimeout('st()',5000);
}
</script>
当我点击这个按钮时,ajax 会启动背景。
<button OnClick="st()">Record</button>
我不知道该怎么做,请有人帮助我。
【问题讨论】:
-
st() 是对脚本的函数调用,它开始执行一个页面 record.php,它从 ip camera 获取帧。
-
您正在引入一个不需要的全局
xmlhttp并且您没有关闭字符串http://localhost/IPCAM/start.php。setTimeout的首选语法是setTimeout(function, timer)而不是(string, timer)。 -
抱歉这是我的错字,但是这个脚本运行良好并且成功录制了视频。只是现在我想在点击录制按钮时显示图像加载。这可能吗?跨度>
标签: php javascript jquery ajax radajaxloadingpanel