Your best bet would be to change the body class (either add class or remove class) with jQuery after the ajax call as a callback.
$.ajax({
url: "yourloop.php",
context: document.body
}).done(function() {
$(this).addClass("finished-loop");
});