Using jQuery and PHP to Display Data
<p><strong>Background</strong></p>

<p>I don't know much about PHP or jQuery, and I was wondering if what I'm trying to do is possible. I have a server with access to a database behind a firewall. I want to use jQuery to push the data out to an external server's PHP script every 5 seconds where it will be displayed publically. This external server does not have access to a database that I know of. If this is possible, what would I have to put in the PHP script?</p>

<p><strong>What I Have So Far</strong></p>

<p>internalServer.js:</p>

<pre><code>function timedPost() {
    $.ajax({
        type: 'POST',
        url: 'http://externalserver/display.php',
        crossDomain: true,
        data: '{"some":"json"}',
        dataType: 'json'
    });
    setTimeout("timedPost()", 5000);
}
</code></pre>

<p>externalServer.php</p>

<pre><code>&lt;?php 
    switch ($_SERVER['HTTP_ORIGIN']) {
        case 'http://internalServer': case 'https://internalServer':
        header('Access-Control-Allow-Origin: '.$_SERVER['HTTP_ORIGIN']);
        header('Access-Control-Allow-Methods: POST, GET, OPTIONS');
        header('Access-Control-Max-Age: 1000');
        header('Access-Control-Allow-Headers: Content-Type');
        break;
    }
?&gt;
</code></pre>
