jadprash Posted October 28, 2020 Share Posted October 28, 2020 $(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) } }); } 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 get displayed on url page signup.php. am I accesing the form properly in register function.......please guide....Thanks Quote Link to comment https://forums.phpfreaks.com/topic/311650-ajax-message-gets-skipped-to-the-url-page-not-on-required-div/ Share on other sites More sharing options...
requinix Posted October 28, 2020 Share Posted October 28, 2020 If the problem is that a message appears in signup.php then have you considered removing the message? Quote Link to comment https://forums.phpfreaks.com/topic/311650-ajax-message-gets-skipped-to-the-url-page-not-on-required-div/#findComment-1582120 Share on other sites More sharing options...
jadprash Posted October 29, 2020 Author Share Posted October 29, 2020 Even if I remove the message it will go to the sign up. php page. Sign.php validated the form and should display the messages inside the model-footer div.... Quote Link to comment https://forums.phpfreaks.com/topic/311650-ajax-message-gets-skipped-to-the-url-page-not-on-required-div/#findComment-1582121 Share on other sites More sharing options...
requinix Posted October 29, 2020 Share Posted October 29, 2020 There's code in there that says to do a redirect to whatever the response.url was. Tried removing that? Quote Link to comment https://forums.phpfreaks.com/topic/311650-ajax-message-gets-skipped-to-the-url-page-not-on-required-div/#findComment-1582122 Share on other sites More sharing options...
jadprash Posted October 30, 2020 Author Share Posted October 30, 2020 It still skip on url page Quote Link to comment https://forums.phpfreaks.com/topic/311650-ajax-message-gets-skipped-to-the-url-page-not-on-required-div/#findComment-1582151 Share on other sites More sharing options...
requinix Posted October 30, 2020 Share Posted October 30, 2020 Not sure what that is supposed to mean, but if you're saying that it's still redirecting then either you didn't remove the redirect or there's another one somewhere in there that you'll need to remove as well. Quote Link to comment https://forums.phpfreaks.com/topic/311650-ajax-message-gets-skipped-to-the-url-page-not-on-required-div/#findComment-1582152 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.