0

I want to display a loading gif before load and hide it after load. Right now I have this:

<div id="loading-image" style="display: none">
  <i class="fa fa-cog fa-spin fa-3x fa-fw"></i>
  <span class="sr-only">Loading...</span> 
</div>
$("#82348").submit(function(event) {
  event.preventDefault();
  var form = $(this);

  $.ajax({
    type: "post",
    url: "{{ url('search') }}",
    dataType: "json",
    data: form.serialize(),
    beforeSend: function() {
      $('#searchResults').empty(); $("#loading-image").show(); 
    },
    success: function(data) {
      $("#loading-image").hide();
      // rest of ajax

However this is not working. Nothing is happening. Any suggestions?

Rory McCrossan
  • 331,213
  • 40
  • 305
  • 339
harunB10
  • 4,823
  • 15
  • 63
  • 107

0 Answers0