title: Changing background image using jQuery and AJAX
body: <p>I'm trying to write a code to load asynchronously a background every "N" seconds.</p>
  
  <p>OK! NOW EVERYTHING WORKS! But the first image start after 15 seconds. How to load at the end of page load?</p>
  
  <pre><code>(function(jQuery) {
      window.setInterval(function() {
          jQuery.ajax({
              url: 'http://example.com/background.php',
          }).done(function(data) {
              console.log("done Ok!");
              var newImage = new Image();
              newImage.onload = function() {
                  jQuery('body').css({"background-image": data, "color": "red !important"});
                  console.log("ok2!");
              };
              newImage.src = data;
          });
      }, 15000);
  })(window.jQuery);
  </code></pre>
  
  <p>QUESTION SOLVED, BUT NOW I NEED how to load in background the background image.</p>
  
  <p>Here the question:
  <a href="https://stackoverflow.com/questions/25766943/changing-background-image-using-jquery-and-ajax-but-async-and-in-background">https://stackoverflow.com/questions/25766943/changing-background-image-using-jquery-and-ajax-but-async-and-in-background</a></p>