I have the following code that is supposed to display 3 products when the page loads:
for(i=0;i<3;i++) {
document.forms['search_info'].elements['page'].value = i+',1,'+(i+1);
var jsonData = $('#search_info').serializeArray();
var page = document.forms['search_info'].elements['page'].value.split(',');
var limitData = {'name':'limit','value': page[0]+','+page[1]};
jsonData.push(viewData);
jsonData.push(limitData);
$.ajax({
type: "GET",
dataType: "json",
url: 'index.php',
cache: false,
data: jsonData,
success: function(data) {
var text = data.output;
var el = $('#scroller');
el.append('<li>' + text + '</li>').hide().fadeIn(450);
}
});
}
and it actually does the job, the only problem is the order of products; every time I reload the page the items appear in a random order.
Any idea why this is happening? How can I fix this issue?