I have a form login that do the loginCheck using ajax,
If I type the wrong password, it just displays an alert message, but if I use the correctly password it redirect me to the admin page.
The problem is if I call $('html').html(data);
after the login check in ajax, the bootstrap components are not rendered perfectly. For example, nothing happens if I click the dropdown menu, but if I admin page directly, everything works perfectly.
Is there something wrong with using$('html').html(data);
when also using bootstrap?
Code:
$(document).ready(function() {
$('#formlogin').on('submit', function(e) {
// don't let the browser submit the form
e.preventDefault();
var login = $('#usuario').val();
var senha = $('#senha').val();;
if(login.length > 1 && senha.length > 1) {
$.ajax({
url: 'http://localhost:8080/Test/doLogin',
async: true,
cache: false,
type: 'POST',
data: {"usuario.nome":$("#usuario").val(), "usuario.senha":$("#senha").val(),
dataType: 'text',
},
success: function(data) {
$('html').html(data);
}
});
} else {
alert("Login e Senha devem ser preenchidos.");
}
return false;
});
});