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
  • 306,214
  • 37
  • 269
  • 303
harunB10
  • 2,927
  • 8
  • 42
  • 75

0 Answers0