0

記録ボタンをクリックすると実行を開始する次のスクリプトがあります。画像をアップロードするときに通常表示されるものと同じ記録ボタンをクリックしたときに画像を表示したい...これはスクリプトです:

<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>

誰かが私を助けてください。

4

2 に答える 2

1

id loadingDiv の div を追加し、コードをこれに変更します

<script>
function st()
{
                        if (window.XMLHttpRequest)
                        {
                            xmlhttp=new XMLHttpRequest();
                        }
                        else
                        {
                            xmlhttp=new ActiveXObject('Microsoft.XMLHTTP');
                        }
                        xmlhttp.onreadystatechange=function()
                        {
                            if (xmlhttp.readyState==1)
                            {
                            document.getElementById("loadingDiv").innerHTML = "<img src='loading.gif'/>";
                            }
                            if (xmlhttp.readyState==4 && xmlhttp.status==200)
                            {
                            alert('RECORDING Start');
                            }

                        }
                        xmlhttp.open('GET','http://localhost/IPCAM/start.php;

                        xmlhttp.send();

setTimeout('st()',5000);
}
</script> 
于 2013-02-28T21:20:24.597 に答える
1

まず、あなたの質問は非常に不明確だと思いますが、試してみましょう:

画像を定義する css クラスがあることを確認してください。

.recordingBackground
{
    background-image: url("record.png");
}

(または単に JavaScript を使用します)

ボタンを作成します。

<input type="button" id="recordButton" value="Record" />

jQuery にボタンをリッスンさせると、要素にクラスを追加できます。

$('#recordButton').live("click", function()
{
    $('#background').addClass('recordingBackground');
    // Or use a similar method (for example: pure javascript).
    // #background is just an example div.
});
于 2013-02-28T21:25:01.910 に答える