Redirect upon login

I have a bootstrap login popup. Upon login into the system throught the bootstrap popup I need to redirtect the client to either myAccount page or myCart page.

		$('#login-form').bootstrapValidator({
			message: 'This value is required',
			submitButton: '$login-form button[type="submit"]',
			live: 'enabled',
			
        	
        	 feedbackIcons: {
	            valid: 'glyphicon glyphicon-ok',
	            invalid: 'glyphicon glyphicon-remove',
	            validating: 'glyphicon glyphicon-refresh'
	        },
	        
	        fields: {

            username: {
            	group: 'col-sm-2',
                message: 'The username is not valid',
                validators: {
                    notEmpty: {
                        message: 'The username is required and can\'t be empty'
                    },
                    stringLength: {
                        min: 2,
                        max: 30,
                        message: 'The username must be more than 2 and less than 30 characters long'
                    }
                   
                }
            },

            loginPassword: {
            	group: 'col-sm-2',
                validators: {
                    notEmpty: {
                        message: 'The password is required and can\'t be empty'
                    }
                   
                }
            }
            }
        }).on('success.form.bv', function(e) {
     // alert(100)
        // Prevent form submission
      e.preventDefault();
      // Get the form instance
      var $form = $(e.target);
      // Get the BootstrapValidator instance
      var bv = $form.data('bootstrapValidator');
	 
      // Use Ajax to submit form data
      $.ajax({
          type: 'POST',
          url: '/includes/login.cfc?method=doLogin',
          data: $("#login-form").serialize()
        })
        .done(function(result) {
          //alert('Here');
          if (result == 'yes') {
           // alert('Valid');
            $('#myModal').modal('hide');
			//alert(goto);
			location.reload(true);
			//window.location.reload(true);
			//= '#session.gotoPage#';	
            	
          } else {
            //alert('Not Valid');
            $(".alert-danger").show();
            $("#login-form").data('bootstrapValidator').resetForm();
          }
        })
        .fail(function() {
          alert("error");
        })
        .always(function() {
         
        });
    });

Open in new window

LVL 19
erikTsomikSystem Architect, CF programmer Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Gurpreet Singh RandhawaCEOCommented:
and what is the problem you are facing, not reloading or reloading or what?, any error you are getting
0
gdemariaCommented:
I think the author forgot to ask a question..
0
erikTsomikSystem Architect, CF programmer Author Commented:
Well the question is how to redirect in to a different url.   I need to redirect the client to either myAccount page or myCart page. If the client have something in the cart then redirect to the cart page other wise to my account page
0
Become a Certified Penetration Testing Engineer

This CPTE Certified Penetration Testing Engineer course covers everything you need to know about becoming a Certified Penetration Testing Engineer. Career Path: Professional roles include Ethical Hackers, Security Consultants, System Administrators, and Chief Security Officers.

Gurpreet Singh RandhawaCEOCommented:
In your AJAX call return the json data and parse it and based upon write two different logics to navigate the user
0
gdemariaCommented:
The question then is, how do you know if the cart has something in it or not?
You could build that into your CFC do Login script  and just return the URL of where the user should be redirected.

Then in jquery do a href location to that returned variable
0
Gurpreet Singh RandhawaCEOCommented:
correct where there is a cfc, he can write a function which can return multiple structs and one such can be to convert to json to know what is being returned and if that is cart is 1 , navigate to the cart else to the account section
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ColdFusion Language

From novice to tech pro — start learning today.