当ajax开始在后台运行时显示加载图像 [英] showing a loading image when ajax start running in background
问题描述
我有以下脚本,当我单击record按钮时,该脚本开始运行. 我想显示一个图像,当我单击记录"按钮时,该按钮与在我们上载图像时通常显示的图像相同. 这是脚本:
I have the following script which starts running when i click on record button . I want to show a image when i click on record button which is same as the one displayed usually when we upload images on... this is the script:
<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启动背景.
And this the button when i click on this button the ajax starts background.
<button OnClick="st()">Record</button>
我不知道要这样做,请有人帮我.
I have no Idea to do this please can someone help me .
推荐答案
首先,我发现您的问题不清楚,但让我尝试一下:
To begin with I find your question very unclear, but let me try:
确保您具有定义图像的css类:
Make sure that you have a css class that defines the image:
.recordingBackground
{
background-image: url("record.png");
}
(或仅使用javascript)
(Or just use javascript)
创建按钮:
<input type="button" id="recordButton" value="Record" />
让jQuery听按钮,您可以将类添加到元素:
Make jQuery listen to the button and you can add the class to the element:
$('#recordButton').live("click", function()
{
$('#background').addClass('recordingBackground');
// Or use a similar method (for example: pure javascript).
// #background is just an example div.
});
这篇关于当ajax开始在后台运行时显示加载图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!