***I have the above jQuery file, which Ajaxify two form login and signup through function submitForm and registerForm. Both the function works properly. However registerForm doesn’t Ajaxify the success message on model-footer div, which is below form, the message gets displayed on URL page signup.php. am I accessing the form properly in the register function…please guide…Thanks ***
$(function(){
$('.form').on('submit', function(e){
e.preventDefault();
$form = $(this);
submitForm($form);
$reg = $('register');
registerForm($reg);
});
$('#forgot-password').on('click', function( e ){
e.preventDefault();
$('#login').modal('hide');
});
});
function submitForm($form){
$footer = $form.parent('.modal-body').next('.modal-footer');
$footer.html('<img src="public/images/ajax-loader.gif">');
$.ajax({
url: $form.attr('action'),
method: $form.attr('method'),
data: $form.serialize(),
success: function(response){
response = $.parseJSON(response);
if(response.success){
if(!response.signout){
setTimeout(function(){
$footer.html( response.message );
window.location = response.url;
},5000);
}
$footer.html( response.message );
}
else if(response.error){
$footer.html( response.message );
}
console.log(response)
}
});
}
function registerForm($form){
$footer = $form.parent('.modal-body').next('.modal-footer');
$footer.html('<img src="public/images/ajax-loader.gif">');
var data = new FormData('register');
$.ajax({
url: $form.attr('action'),
data: data,
type: "POST",
processData: false,
contentType: false,
success: function(response){
response = $.parseJSON(response);
if(response.success){
if(!response.signout){
setTimeout(function(){
$footer.html( response.message );
window.location = response.url;
},5000);
}
$footer.html( response.message );
}
else if(response.error){
$footer.html( response.message );
}
console.log(response)
}
});
}