我想在加载前显示加载gif并在加载后隐藏它。现在我有这个:
<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
然而这不起作用。什么都没发生。有什么建议吗?