I have a form and typing the zip code shows a loading gif while I load the street, the neighborhood and etc.
The problem is that as the user goes down the form, the loading gif does not appear because it gets stuck at the top of the form giving the impression that the site is locked.
I would like the upload image to accompany the screen, appearing right in the middle of the screen, so the user can see that a load is happening.
I accept other suggestions that fit the case.
HTML / PHP:
<div id="loader" class="loader" style="display: none">
<img width="35px" height="35px" src="{{ asset('img/ajax-loader.gif') }}" class="img-responsive center-block" alt="loader">
</div>
<div class="form-group">
<label for="cep">CEP:</label>
<input type="text" id="cep" name="cep" class="form-control important" value="{{ old('cep') }}">
</div>
Script:
$('#cep').on('blur', function(){
var f_empresa_nova = $('#f_empresa_nova').serializeArray();
var url = "/cep";
loader('on');
$.post(url, f_empresa_nova, function(data){
loader('off');
$('#logradouro').val(data.logradouro);
$('#bairro').val(data.bairro);
$('#cidade').val(data.cidade);
$('#uf').val(data.uf);
$('#cep').removeClass();
$('#cep').addClass("form-control required");
});
});