How can I be sure my Ajax call has fully completed?
<p>I have the following code:</p>

<pre><code>   $.ajax({
        cache: false,
        url: "/Administration/" + entity + "s/Update",
        data: { pk: pk, rk: rk, fld: type, val: val },
        success: function () {
            disableLoadingIcon();
            if (idArr.substr(0, 8) == 'Position') {
                location.reload(); 
            }
        }
    }); 
</code></pre>

<p>When a user changes some data the code updates the database. There is code that comes before this that picks the data values and it all works good. </p>

<p>When the user changes the Position column the database gets changed and I wanted to trigger a refresh of the screen (it's a report screen sorted by position).  The refresh works but it seems like it is out of sync. I have the location.reload() in the success area but is it possible that is getting run before the Ajax has completed?</p>

<p>Is it possible that this kind of refresh is taking place before the database has been properly updated? When I do another refresh of the page manually from the browser the data always appears in the correct order. </p>
