Ajax call from phonegap to login in Yii fails
I'm doing my first phonegap app and I run into login problem. I have an appLogin action in the site controller and I know it reaches the controller's action and logs in - anyway the credentials get validated and login is successful. But the ajax call in app fails to get response. If I comment out the login part and just echo something the ajax call is succesful and receives the response. I know I'm probably missing something basic regarding authentication. What is it?
- BusinessBox.prototype.serLogin = function(){
- var me = this;
- alert("ajax login "+me.credentials.loginform.username);
- $.ajax({
- type: "POST",
- url: serverActions.appLogin(),
- dataType: "json",
- data: me.credentials
- }).done(function( obj ) {
- alert(obj);
- if(obj) {
- me.loggedIn = true;
- alert(obj);
- } else {
- me.loggedIn = false;
- alert("not logged in");
- }
- }).fail(function(err){
- alert("error log in");
- });
- }
and here is the php
- public function actionAppLogin() { $model=new LoginForm; // if it is ajax validation request if(isset($_POST['ajax']) && $_POST['ajax']==='login-form') { echo CActiveForm::validate($model); Yii::app()->end(); } // collect user input data if(isset($_POST['loginform'])) { $request = $_POST['loginform']; $model->attributes=$request; if($model->validate() && $model->login()){ //it reaches here echo 111; } else { echo 444; } } else { echo 222; } }