I use jquery loading, and then, as soon as the content is loaded into a div, I want to change some tags to language-dependent variables.
My problem is that I need to use setimeout to make the script wait long enough for the elements to be ready for editing.
When I use the callback function parameter, the elements that I want to edit are apparently not ready because they are not set. I hate using setimeout because it limits everyone to the slowest setting, and invariably some connections will be even slower than that.
Apparently, the callback method means that the ajax method got the html back, but it does not guarantee that the imported elements are really ready in dom.
Does anyone have any ideas?
current code
$("#content-basket").load("/BasketPage.htm?time=" + now.getMilliseconds()); ... ... setTimeout("timedbasket();", 500); ... ... function timedbasket() { alert($('#basketlegend')); $('#basketlegend').html(basketlabel); }
I would like to be able to use
$("#content-basket").load("/BasketPage.htm?time=" + now.getMilliseconds(), "", timedbasket());
Here is the source of basket.htm
<tr> <td> <div id="basket"> <fieldset> <legend><span id="basketlegend"></span></legend> <table id="baskettbl" border="0" class="basket-table"> <tbody> <tr class='total'> <td> <span id="empty"></span> </td> </tr> </tbody> </table> </fieldset> </div> </td> </tr>
source share