Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I actually wrote up an answer to a different question, that seems to apply here: <a href="https://stackoverflow.com/a/10012302/166661">https://stackoverflow.com/a/10012302/166661</a></p> <p>You've got a server that will return to you information -- you could place this information in an <code>IFRAME</code>... or you can call a JavaScript function to retrieve that information and display it in a location (<code>DIV</code>) you set aside on your page.</p> <p>Here is a sample HTML page that will retrieve information from the server using AJAX</p> <pre><code>&lt;html&gt; &lt;head&gt; &lt;script type="text/javascript"&gt; function getAreaInfo(id) { var infoBox = document.getElementById("infoBox"); if (infoBox == null) return true; var xhr = new XMLHttpRequest(); xhr.onreadystatechange = function() { if (xhr.readyState != 4) return; if (xhr.status != 200) alert(xhr.status); infoBox.innerHTML = xhr.responseText; }; xhr.open("GET", "info.php?id=" + id, true); xhr.send(null); return false; } &lt;/script&gt; &lt;style type="text/css"&gt; #infoBox { border:1px solid #777; height: 400px; width: 400px; } &lt;/style&gt; &lt;/head&gt; &lt;body onload=""&gt; &lt;p&gt;AJAX Test&lt;/p&gt; &lt;p&gt;Click a link... &lt;a href="info.php?id=1" onclick="return getAreaInfo(1);"&gt;Area One&lt;/a&gt; &lt;a href="info.php?id=2" onclick="return getAreaInfo(2);"&gt;Area Two&lt;/a&gt; &lt;a href="info.php?id=3" onclick="return getAreaInfo(3);"&gt;Area Three&lt;/a&gt; &lt;/p&gt; &lt;p&gt;Here is where the information will go.&lt;/p&gt; &lt;div id="infoBox"&gt;&amp;nbsp;&lt;/div&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>And here is the info.php that returns the information back to the HTML page:</p> <pre><code>&lt;?php $id = $_GET["id"]; echo "You asked for information about area #{$id}. A real application would look something up in a database and format that information using XML or JSON."; ?&gt; </code></pre> <p>Hope this helps!</p>
    singulars
    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. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      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