I'm trying to set up a feed that loads every five seconds. I've got the first part to work where it loads while you're just sitting on the site. My next issue now is that it just pops up suddenly, so I'm trying to get it to look smoother.
function FinalizeFeed(result) { $(".useractivity").html(result); } function LoadFeedData() { var dataString = "action=loaduserfeed"; $.ajax({ type: "POST", url: "/core/functions.d/feed.php", data: dataString, cache: false, success: function(result){ $(".post-loading").html('<center><i class="fa fa-circle-o-notch fa-spin fa-5x fa-fw"></i><span class="sr-only">Loading...</span></center>').fadeOut("slow"); setTimeout(FinalizeFeed(result), 2000); } }); } So my thought was create the FinalizeFeed function. Works fine, but still just pops up. If I don't add the Finalize function under the .post-loading.html the spinner shows up and looks real nice, but doesn't really help with loading new data in. with the setTimeout I thought it would wait, but the spinner doesn't even show up. Does anyone see what the issue is with this code?
beforeSend: function() { // spinner code here }then wipe it postsuccessfunction, ie. after the timeout or in thecomplete: function() {}FinalizeFeed()) is pointless, really.setTimeout(function() { $(".useractivity").html(result); }, 2000);would suffice just fine. Functions are meant for re-usability purposes. This appears to be a one-off case.