erikTsomik
asked on
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() {
});
});
and what is the problem you are facing, not reloading or reloading or what?, any error you are getting
I think the author forgot to ask a question..
ASKER
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
In your AJAX call return the json data and parse it and based upon write two different logics to navigate the user
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.