php javascript callback function
<pre><code>O3Global.Ajax.loadXML('Lackeys', 'hire', aPost, function (oResponse) {
    hireCallback(oResponse, iCurLackey, iCredits);
}, Lackeys.cancel);
</code></pre>

<p>Is the oResponse calling back 2 times?  how to handle this call back?</p>

<pre><code>this.doHire = function() {
    if (!aLackeys[iCurLackey]) return;

    // Fetch credits
    var oCredits = $("#lackey_hire_credits");
    var iCredits = oCredits.val() * 1;
    if (iCredits &lt;= 0) {
        alert('You must enter a valid number of credits');
        oCredits.focus();
    }
    else if (iCredits &gt; iAvailableCredits) {
        alert('You do not have enough credits. You only have' + iAvailableCredits + '.');
        oCredits.val(iAvailableCredits);
        oCredits.focus();
    }
    else {
        // Send the Ozone event
        var aPost = new Array();
        aPost['type'] = iCurLackey;
        aPost['credits'] = iCredits;
        O3Global.Ajax.loadXML('Lackeys', 'hire', aPost, function(oResponse) {
            hireCallback(oResponse, iCurLackey, iCredits);
        }, Lackeys.cancel);

    }
}

function hireCallback(oResponse, iLackey, iCredits) {
    // Fetch data
    var sCity = oResponse.getElementsByTagName('city')[0].firstChild.data;

    // Process
    aLackeys[iLackey].hired(iCredits, sCity);
    Lackeys.modCredits(-iCredits);

    // Close the box
    Lackeys.cancel();
}​
</code></pre>
