Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Sure!</p> <p>Client side:</p> <pre><code>&lt;script type="text/javascript"&gt; //The first image to load CurrentImage="http://images.google.com/intl/en_ALL/images/logos/images_logo_lg.gif"; //The Image, eg: &lt;img id=imgBox src=foo.jpg&gt; ImgBox = document.getElementById('imgBox'); function CheckForImg() { var ajaxRequest; // The variable that makes Ajax possible! try{ // Opera 8.0+, Firefox, Safari ajaxRequest = new XMLHttpRequest(); } catch (e){ try { ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try{ ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP"); } catch (e){ // Something went wrong alert("Ajax is kinda disabled :(\n you won't be able to do some stuff around :("); return false; } } } // Create a function that will receive data sent from the server ajaxRequest.onreadystatechange = function(){ if(ajaxRequest.readyState == 4){ var str = ajaxRequest.responseText; if(str != CurrentImage) // we have a new image { ImgBox.src = str; currentImage = str; } } ajaxRequest.open("GET", "getCurrentImagUrl.php", true); ajaxRequest.setRequestHeader("Content-type", "application/x-www-form-urlencoded") ajaxRequest.send(null); } &lt;/script&gt; </code></pre> <p>Now we need a way to keep the client posted, so either we put that to a frequency, or show a button to press which is way better and more efficient:</p> <p>Method 1(Button):</p> <pre><code>&lt;Button onclick="CheckForImg();"&gt;Check For Image!&lt;/button&gt; </code></pre> <p>Method 2(Periodically check):</p> <p>Simply call </p> <pre><code>SetInterval("CheckForImg", 5000); </code></pre> <p>I'll leave the server side for you :)</p> <p>Any further help is kindly offered.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload