Hi all!
I try to do some ajax call and have in my example three entries with some text content. What I try to do is to randomize one of the three items I get back. It works sometimes, and sometimes now when I do a page refresh. Btw in real cases it could be more than three items.
What have I missed here?
Thanks in advance!
- function successFunction(data) {
- var numberOfItems = data.d.results.length;
- for (var i = 0; i < data.d.results.length; i++) {
- var randItem = Math.floor(Math.random() * numberOfItems) + 1;
- var randText = data.d.results[(randItem)].QuoteText;
- $('.quoteText').html(randText);
- }
- }