I’m just writing a simple plug-in that will fill in div placeholders in the page body, on page load, with info fetched from a database via AJAX. It’s all working, but I have reservations over it’s efficiency and whether place1 will always show cake1 and place2 always cake2 due to the asynchronicity of AJAX.
So simplifying:
[CODE]
<body onload=”show_recipe(‘place1’, ‘cake1’); show_recipe(‘place2’, ‘cake2′)”>
…
<div id=’place1′></div>
<div id=’place2’></div>
and
[CODE]
function show_recipe(place, food) {
function recipe_received() {
// Manipulate DOM…
}
send_off_db_request(food, recipe_received)
}
Is there a better way to structure this?