The following code works perfectly in the Windows 10 Browser, but it does not work in the Android / IOS mobile browser completely, and MacOS gives a message telling the user that it is not working well. The problem seems to be in: success: function(result)
.
The rest of the code works, the only thing that does not work is div $ ('# warning'), so I tested it in isolated parts. When run in parts it works, but it's within full code not.
$(function () {
$("form[name='form-inscricao']").submit(function(e){
e.preventDefault();
var $form = $(this);
var $inputs = $form.find("input, select, button, textarea");
var serializedData = $form.serialize();
$inputs.prop("disabled", true);
$.ajaxSetup({
contentType: "application/x-www-form-urlencoded; charset=UTF-8"
});
$.ajax({
url:'https://www.example.com/wp-content/themes/example.com/enviar.php',
type: 'post',
dataType: 'html',
data: serializedData,
async: false,
beforeSend: function(){
$('.loader').show();
$('#aviso').text('');
},
error: function() {
console.log('Something went wrong');
},
success: function(result){
$('#aviso').append(result).css({opacity:1.0}).delay(1000).animate({opacity : 0},500);
},
complete: function(){
$('.loader').hide();
$form.get(0).reset();
$inputs.prop("disabled", false);
}});
});
});