Yii Framework Forum: Yii:: Log And Model Creation Not Working When Controller Is Being Called From Ajax/json - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Yii:: Log And Model Creation Not Working When Controller Is Being Called From Ajax/json Rate Topic: -----

#1 User is offline   CTala 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 97
  • Joined: 17-August 11
  • Location:Chile

Posted 14 January 2013 - 01:55 PM

Yii:: log and Model creation not working when Controller is being called from AJAX/JSON

I did a widget that implements and html5 uploader in my Yii APP.

The upload, and the copy of the files works great.
The call to functions as "Path Of Alias" works great too.

The problem is that saving models is not working under these conditions and I do not know why.
I started to log the variables with Yii::log and I realized that is not being called at all, or at least is not changing the content of the log file. ( It works in other controllers without trouble )

I read that someone had a similar trouble and he fixed it with Yii::app()->end(); but this is not working for me.

It seemd that every Yii function that is left for the end is not working.

Any one has any idea ? It will really appreciated !! :D
--
MSc. Cristian Tala Sánchez
0

#2 User is offline   CTala 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 97
  • Joined: 17-August 11
  • Location:Chile

Posted 14 January 2013 - 02:17 PM

The Yii::log function started to work after I force a Yii->app()->end before each die().

 function myDie($msg)
    {
        Yii::app()->end();
        die($msg);
    }


I still have the trouble of the model that has not beeing save().
--
MSc. Cristian Tala Sánchez
0

#3 User is offline   CTala 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 97
  • Joined: 17-August 11
  • Location:Chile

Posted 14 January 2013 - 02:42 PM

And using the following I realized that I had an error in the model.

function myLog($msg, $sufijo = "[LOG]") {
        if (is_array($msg)) {
            foreach ($msg as $key => $value) {
                if (is_array($value)) {

                    foreach ($value as $key_2 => $value_2) {
                        YII::log($sufijo . $key_2 . ":\t" . $value_2);
                    }
                } else {
                    YII::log($sufijo . $key . ":\t" . $value);
                }
            }
        } else {
            Yii::log($sufijo . $msg);
        }
    }

--
MSc. Cristian Tala Sánchez
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users