dcsimg
www.webdeveloper.com
Results 1 to 3 of 3

Thread: [RESOLVED] Registration page stalls after using modal

  1. #1
    Join Date
    Jan 2015
    Location
    Dallas
    Posts
    138

    resolved [RESOLVED] Registration page stalls after using modal

    The registration page worked fine until I added a modal. The modal lays out a non-disclosure agreement. When the user click the Continue button on the modal, the flow is sent back to the main page. But the ajax no longer processes. The page just sits there.

    Firstly, I harvest the input variables from the registration form. If everything there is okay, then it allows the user to click the Registration button, which then shows a modal with an NDA on it. Once they check the "I agree checkbox", then the Continue button becomes enabled for them to click.

    HTML Code:
    $('#register').click(function(){
    
    	var setservice = $('#service').val();
    	if(setservice == "22"){
    		$('#serviceErr').html("Please Select a Service").show().delay(3000).fadeOut("slow");
    		$('#service').focus();
    		return false;
    	}
    
    	var setfname = $('#fname').val();
    	if(setfname == ""){
    		$("#fnameErr").html("Field cannot be Empty").show().delay(3000).fadeOut("slow");
    		$('#fname').focus();
    		return false;
    	}
    
    	var setlname = $('#lname').val();
    	if(setlname == ""){
    		$("#lnameErr").html("Field cannot be Empty").show().delay(3000).fadeOut("slow");
    		$('#lname').focus();
    		return false;
    	} ...
    
    	$('#myModal').modal('show');
    		$('#agree').click(function(){
    			/* CHECK THE AGREEMENT BOX */
    			if ($('#agree').is(':checked')) {
    				$('#continue').prop('disabled', false);
    			} else {
    				$('#continue').prop('disabled', true);
    			}
    	});
    
    });
            
    $('#continue').click(function(){
            $('#myModal').modal('hide');
    	$.ajax({
    	        url	: 'register.php',
    		type 	: 'POST',
    		async	: true,
    		data 	: {
    			'register'	: 1,
    			'fname'		: setfname,
    			'lname'		: setlname,
    			'phone'		: setphone,
    			'email'		: setemail,
    			'pwd1'		: setpwd1,
    			'timezone'	: settimezone,
    			'captcha'	: setcaptcha,
    			'service'	: setservice
    		},
    		success:function(re){
    			if(re == "error"){
    				errorpage();
    			}
    			if(re == "0"){
    				window.location.replace("https://www.website.com/confirmemail.html");
    			}
    			if(re == "2"){
    				$('#captchaErr').html("CAPTCHA Incorrect").show().delay(3000).fadeOut("slow");
    				$('#captcha').focus();
    				return false;
    			}
    		}
    
    	});
    });
    I'm new to using modals, so I'm sure I've done something silly here. Any help would be appreciated. Thanks.

  2. #2
    Join Date
    Jan 2015
    Location
    Dallas
    Posts
    138
    Like I said: something silly.

    The fix: move the continue button click event inside the register button click event. That's why it was stalling; it'd lost scope of the variables and had nothing to process.

    Fell asleep at the wheel
    Last edited by Landslyde; 09-01-2016 at 06:26 AM.

  3. #3
    Join Date
    Mar 2007
    Location
    localhost
    Posts
    3,708
    You should ask framework questions in the frameworks forum
    --> JavaScript Frameworks like JQuery, Angular, Node <-- ... and please remember to wrap any code you have in forum tags:-
    [CODE]...[/CODE] [HTML]...[/HTML] [PHP]...[/PHP]

    If you can't think outside the box, you will be trapped forever with no escape...

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles