I’m new to jquery and even after looking at examples it eludes me. I am not using timeout: for the ajax options because the server responds fine, i just need an actual 1000ms delay to give Ruby’s Resque/Redis a set amount of time to move the jobs into the queue. I just want to run the main functio() after 1000 seconds (the setTimeout at the bottom is for the 2nd half of the process, which already works great)
$(function() {
$.ajax({
type: "POST",
url: "/percentcomplete",
dataType: "json",
success: function(data) {
if (data != null) {
$("#status").fadeIn();
if (data.name === "PostSaver") {
$(".refreshing").fadeIn();
} else {
$(".rebuilding").fadeIn();
}
setTimeout(refreshStatus, 1000);
}
}
});
});
Try this: