Note that there are some explanatory texts on larger screens.

plurals
  1. POHow do I refresh an HTML file when the contents of a different file change?
    primarykey
    data
    text
    <p>I have this situation with a device accessing a simple MySQL database using PHP. When I do a search, the results are written in an HTML file.</p> <p>I have a second device (very basic android tablet) that has this HTML file opened. Using live.js it refreshes when it's contents change. What I need is this: a static message saying something like "Waiting for search results" and only when the contents of the page change the results are shown...</p> <p>Something like this: On the tablet load 1.html (waiting for search results). When contents of page 2.html change (there was a search query), display that (2.html). After a push of a button (user input), let's go back to 1.html and wait for the contents of page 2.html to change again.</p> <p>With live.js alone I can only watch for the file that's currently open...</p> <p>Any idea on how I can achieve this? Thanks a bunch.</p> <p><strong>[EDIT - SOLVED]</strong> I got this to work like this: when the user of the tablet pushes a button it runs a PHP script that replaces the contents of the file (the previous search results) with the "waiting for results" text. Of course, it has live.js in the head, and when a new search occurs, the page reloads with the new search results.</p> <p>It was easier than I thought I was overthinking it.</p> <p>The PHP script:</p> <pre><code>&lt;?php ob_start(); $myFile = 'ana.html'; unlink($myFile); $fh = fopen($myFile, 'w') or die ("can't open file"); $stringData = '&lt;html&gt; &lt;head&gt; &lt;title&gt;Rezultatele cautarii&lt;/title&gt; &lt;link rel="stylesheet" href="style.css"&gt; &lt;script src="live.js"&gt;&lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;h1 class="button"&gt;Asteptam cererea&lt;/h1&gt; &lt;/body&gt; &lt;/html&gt;'; fwrite($fh, $stringData); fclose($fh); header('Location: '.$myFile); die(); ?&gt; </code></pre>
    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.
 

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