0
I developed a form, when the user clicks on the send button a GIF appears and then a modal has to appear saying that the information has been sent so far all right the GIF works normal but when the form is submitted the GIF goes away and the Popupdoes not appear like to know if I am doing something wrong follows my Javascript code:
$("#submit-btn").click(function (e) {
e.preventDefault();
var data = $('form').serializeArray();
if ($(this).hasClass('btn-warranty')) {
var inputRangeValue = $('.final-value').first().text();
var specialty = {name: 'specialty', value: $('#specialty').val()};
var value = {name: 'value', value: inputRangeValue + '000'};
data.push(specialty);
data.push(value);
}
if ($(this).hasClass('btn-indenizometro')) {
var question_1 = $('input[name=question_1]:checked').val();
var question_2 = $('input[name=question_2]:checked').val();
var question_3 = $('input[name=question_3]:checked').val();
//var reason = {name: 'reason', value: sessionStorage.tipo };
var monthly = {name: 'monthly', value: $('#monthly-value').text()};
data.push(question_1);
data.push(question_2);
data.push(question_3);
data.push(monthly);
//data.push(reason);
}
var product = {name: 'product', value: window.location.pathname};
data.push(product);
$('.loaderImage').show();
//Ajax post data to server
$.ajax({
type: 'POST',
url: '/request',
data: data,
dataType: 'json',
success: function (data) {
$('.loaderImage').hide();
$('#modal-success').modal('show');
$('form')[0].reset();
},
error: function (data) {
//console.log(data);
}
});
});
NOTE: just remembering that the modal I’m using is from boostrap
What you want to do with a modal within a callback jquery?
– user86792
type when I click to send appears a gif on the button because it takes too long to send the form I implemented this gif more ai when the form and sent it adds up then the popup would have to appear more it does not appear
– Felipe Henrique
Open the Chrome console and see if there is any error. See this simulation that I did. Apparently your code has nothing wrong. Exchange
.click()
for.on( "click", function () { ... });
– user86792
I will add the following: using modals is a bad idea for notification. They are intrusive and get in the way, and it’s an extra click for me, the user. Use something like Notifyjs, much more elegant and it’s just a notification.
– user86792