I have a setup where divs that contain similar data (but ranked differently) need to dynamically load data on start up. To do this I load a PHP page through AJAX and pass a parameter so it knows what rank to query. However in order to load on start I need to call the same function 4 times in a row. Is this syntax correct? Or is there a way to write this without a big list of the same function being called
$(document).ready(function(){
getStuff(1);
getStuff(2);
getStuff(3);
getStuff(4);
});
function getStuff(type) {
$.ajax({
type: "GET"
..........
success: function(html) {
$('[data-id="' + type + '"]').html(html);
}
});
}
<div id="rank1" data-id="1"></div>
<div id="rank2" data-id="2"></div>
<div id="rank3" data-id="3"></div>
<div id="rank4" data-id="4"></div>
$('[data-id="' + type+ '"]')