Sequential AJAX request processing and storage
<p>I'm trying to write a script to sequentially pull data from printers that have a web interface. There are over 500 on a large local network, hence the reason I'd like to call out to the next one once the previous returns (successful or not). I'm having difficulties wrapping my head around callbacks ...if that's the best solution.</p>

<p>Here's where I currently stand (be kind, this is my intro to jQuery/Javascript and this is a proof test). Also, is there a way to build an array from the resulting calls? The reason I've turned to Javascript is that I could not get PHP to behave with the execution times.</p>

<p>Oh, you'll see ASYNC: true below only because I tried w/ false and it did not work (return anything).</p>

<pre><code>function pingDevice(prnList) {
    prnList = ["www.google.com", "amazon.com", "facebook.com", "as923f.com"];
    document.getElementById("myDiv").innerHTML="please wait...";

    $(prnList).each( function(index,printer) {
        $.ajax({
            type: "GET",
            dataType: "html",
            url: "pingTest.php?ping="+printer,
            async: true,
            success: function (data) {
                $('#myDiv').append( $('&lt;div class="prn"&gt;&lt;/div&gt;').html(data) );
                $prnResults[printer] = data;
            },
            error: function () {
                $prnResults[printer] = data;
            }
        });
    });
    $('#myDiv').append( $('&lt;div class="prn"&gt;&lt;/div&gt;').$prnResults );
}
</code></pre>
