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.
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...
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.
With live.js alone I can only watch for the file that's currently open...
Any idea on how I can achieve this? Thanks a bunch.
[EDIT - SOLVED] 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.
It was easier than I thought I was overthinking it.
The PHP script:
<?php
ob_start();
$myFile = 'ana.html';
unlink($myFile);
$fh = fopen($myFile, 'w') or die ("can't open file");
$stringData =
'<html>
<head>
<title>Rezultatele cautarii</title>
<link rel="stylesheet" href="style.css">
<script src="live.js"></script>
</head>
<body>
<h1 class="button">Asteptam cererea</h1>
</body>
</html>';
fwrite($fh, $stringData);
fclose($fh);
header('Location: '.$myFile);
die();
?>