I have a form where users enter 6 numbers, which are collect and stored as variables when the form is submitted. I'm then using AJAX to display a loading screen. I was wondering how to display the numbers entered on the loading screen using AJAX beforeSend function?
$(function() {
$(".submit").click(function() {
var num1 = $("#num1").val();
var num2 = $("#num2").val();
var num3 = $("#num3").val();
var num4 = $("#num4").val();
var num5 = $("#num5").val();
var num6 = $("#num6").val();
var dataString = 'num1=' + num1 + '&num2=' + num2 + '&num3=' + num3 + '&num4=' + num4 + '&num5=' + num5 + '&num6=' + num6;
if (num1 == '' || num2 == '') {
$('.error').fadeOut(200).show();
} else {
$.ajax({
type : "POST",
url : "index.php",
data : dataString,
data : jQuery('#numbers_form').serializeArray(),
beforeSend : function() {
$('#loader').css('display', 'block');
$('#loader').css('margin', 'auto');
},
success : function(res) {
$('#success').css('display', 'block');
}
});
}
});
});