Note that there are some explanatory texts on larger screens.

plurals
  1. POjQuery + jQueryUI: Invoking confirmation dialog-box and refreshing the page.
    primarykey
    data
    text
    <p>I have a problem in creating an AJAX-based form submission which if its response is success, it shows a confirmation string at the top of the form, then resets all of the text input, then shows a confirmation dialog box (which has 2 choices: register another username or go to login page), and finally the two choices mentioned redirect the user to the respective page(s).</p> <pre><code>var $j = jQuery.noConflict(); $j(document).ready(function(){ var disabled = $j("#submitRegister").button("option","disabled"); $j("#submitRegister").button(); function ajax_user_registration(){ var re9me = $j("#mode_exec").val(); var re9sh = $j("#securexhash").val(); var re9xb = $j("#zblank").val(); var re9un = $j("#requsername").val(); var re9pw = $j("#reqpassword").val(); var re9cp = $j("#reqconfpasswd").val(); var re9ab = $j("#agreebox").val(); if((re9xb == "") &amp;&amp; (re9ab != "")){ $j.ajax({ type: "POST", url: "registration.php", data: 'username='+ re9un +'&amp;password='+ re9pw +'&amp;securehash='+ re9sh +'&amp;agreeconfirm='+ re9ab, cache: false, success: function(response){ if(response == 1){ $j("#regboxnotice").removeClass().addClass('message-notice').text('Registration: SUCCESSFUL.').fadeIn(1000); $j("#regAccount")[0].reset(); }else if(response == 0){ $j("#regboxnotice").removeClass().addClass('message-negative').text('Registration: FAILED.').fadeIn(1000); }else{ $j("#regboxnotice").removeClass().addClass('message-negative').text('Registration: FAILED.').fadeIn(1000); } } }); } } /* model function for checking username */ function ajax_check_username(){ var username = $j('#requsername').val(); if(username == ""){ $j('#requsername').css('border', '3px #FFD400 solid'); $j("#regboxnotice").removeClass().addClass('message-notice').text('Username: MIN. 6 CHARS.').fadeIn(1000); }else{ $j.ajax({ type: "POST", url: "validation.php", data: 'username='+ username, cache: false, success: function(response){ if(response == 1){ $j('#requsername').css({'border': '3px #FF0000 solid'}); $j("#regboxnotice").removeClass().addClass('message-negative').text('Username: UNAVAILABLE.').fadeIn(1000); }else{ $j('#requsername').css('border', '3px #009900 solid'); $j("#regboxnotice").removeClass().addClass('message-positive').text('Username: AVAILABLE.').fadeIn(1000); } } }); } } /* model function for checking password */ function ajax_check_password(){ var password = $j('#reqpassword').val(); if(password == ""){ $j('#reqpassword').css('border', '3px #FFD400 solid'); $j("#regboxnotice").removeClass().addClass('message-notice').text('Password: MIN. 6 CHARS.').fadeIn(1000); }else{ $j('#reqpassword').css('border', '3px #009900 solid'); $j("#regboxnotice").removeClass().addClass('message-positive').text('Password: OK.').fadeIn(1000); } } /* model function for checking password-confirmation */ function ajax_check_confpasswd(){ var password = $j('#reqpassword').val(); var confpasswd = $j('#reqconfpasswd').val(); if(confpasswd != password){ $j('#reqconfpasswd').css('border', '3px #FFD400 solid'); $j("#regboxnotice").removeClass().addClass('message-negative').text('Conf. Password: RE-TYPE YOUR PASSWORD.').fadeIn(1000); }else{ $j('#reqconfpasswd').css('border', '3px #009900 solid'); $j("#regboxnotice").removeClass().addClass('message-positive').text('Conf. Password: OK.').fadeIn(1000); } } /* AJAX username checking on-the-fly */ $j('#userzname').keyup(ajax_check_logincomp); $j('#requsername').keyup(ajax_check_username); $j('#reqpassword').keyup(ajax_check_password); $j('#reqconfpasswd').keyup(ajax_check_confpasswd); /* AJAX form submission */ $j('#submitRegister').bind('click', function(event) { ajax_user_registration(); event.preventDefault(); }); }); </code></pre> <p>Anyway, thank you for your attention.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload