I am working on a puzzle game and everytime I load my webpage it takes a while for everything to load. I tried putting a pause until the ajax is loaded but that doesn't seem to fix it. I just want it to load more smoothly. Here is my jsfiddle :
It's not working properly on there but it demonstrates my problem anyways.
Can anyone fix my code for me?
Here is my webpage with the puzzle:
http://www.acsu.buffalo.edu/~jamesber/GameOne.html#
var plant = "";
$.when($.ajax({"url":"http://beta.botanicalapp.com/api/v1/plants/?photo=true"}))
.done(function(fullData){
(function(){
var rand = Math.floor(Math.random()*fullData.length)
while (rand == 3) {
rand = Math.floor(Math.random()*fullData.length)
}
plant = fullData[rand].plant.image_default.url;
})()
startGame();
});