Hi! I have a simple login:
<?php $form=$this->beginWidget('CActiveForm', array(
'id'=>'LoginForm',
'enableClientValidation'=>true,
'clientOptions'=>array('validateOnSubmit'=>true,),)); ?>
<div class="container">
<div class="form-signin">
<h2 class="form-signing-heading">Login</h2>
<label for="inputUsuario" class="sr-only">
Usuario
</label>
<?php echo $form->textField($model,'username',array('class'=>"form-control",'placeholder'=>"Usuario",'id'=>"username")); ?>
<label for="inputPassword" class="sr-only">
Password
</label>
<?php echo $form->passwordField($model,'password',array('class'=>"form-control",'placeholder'=>"Password",'id'=>"password", 'name'=>"password")); ?>
<br>
<?php echo CHtml::Button('Entrar',array("class"=>"btn btn-lg btn-primary btn-block","onclick"=>"login()")); ?>
<?php $this->endWidget(); ;?>
</div>
</div>
The login calls a controller via AJAX:
<script>
function login(){
debugger;
var usuario = $('#username').val();
var password = $('#password').val();
if(usuario == "" || usuario == null || password == "" || password == null){
alert('Ingrese los datos');
}
else{
var data = {'usuario':usuario, 'password':password};
$.ajax({
url: 'login',
type: "POST",
data: data,
dataType: "html",
cache: false,
success: function (response){
alert(response);
if(response == 'error'){
alert('Error al loguear');
}
else{
alert("do something");
}
}
});
}
}
</script>
I have this problem:
¿Any sugesstion?
I searched all the posible solutions but i dont have lucky.
Thanks, Regards