1

Some data processing takes a few seconds once the server has received the client's request...

How can we display an advertisement while the client waits for the payload ?

Same question with and without AJAX

We may not use a library or framework on top of Sails, unless necessary

nico6
  • 167
  • 10

1 Answers1

2

You can do a simple loading graphic, and just replace it with whatever image you want:

HTML

<div class="loader"></div>

CSS

.loader {
  position: fixed;
  left: 0px;
  top: 0px;
  width: 100%;
  height: 100%;
  z-index: 9999;
  background: url('images/page-loader.gif') 50% 50% no-repeat rgb(249,249,249);
}

A simple jQuery function:

$(window).load(function() {
    $(".loader").fadeOut("slow");
})

Demo

Source: Display Loading Image While Page Loads

If you need to do it without jQuery, it is slightly more involved, but you can get more information in this thread:

$(document).ready equivalent without jQuery

Community
  • 1
  • 1
tpie
  • 5,621
  • 3
  • 19
  • 41