1

Can someone help me work out just what I happening here.

I have an ajax function on my controller, when it returns the json it flags up some undefined variable notices even though I have Configure::write('debug', 0) at the top of the function.

Outputting Configure::read("debug") in the function shows zero correctly.

If I change the debug to 0 in the core.php the messages disappear however.

Does anyone know why I may still be getting notices? I really can't think where its going wrong

Thanks

6
  • Is this ajax function calling a method in a different controller? Where are the errors being displayed? Commented Sep 17, 2010 at 12:45
  • No the ajax only calls the Model::find. The errors along with a full debug are output before the json. ie Notice (8): Undefined variable: profession [APP\controllers\calendar_events_controller.php, line 112] Commented Sep 17, 2010 at 13:44
  • 1
    Looks to me like it's trying to execute the code at line 122 before you turn off the debug. Why don't you fix that undefined variable first? [Not the same Leo as the OP] Commented Sep 17, 2010 at 15:57
  • I have fixed the undefined variable and it works fine but why show I get Notices anyway with debug set to zero? Thats what concerns me. Commented Sep 17, 2010 at 16:03
  • 1
    Difficult to say without seeing your code, but I'd suggest that the error occurs before your ajaxMethod turns off debug. As you pointed out, when debug==0 in core.php the error messages disappear. The ajaxMethod is overriding the core setting for that method only. Before and after ajaxMethod, debug is whatever it is set to in core.php. Try outputting the debug level before you set it - preferably in the calling method and also before line 122. That might give you a better picture of what is happening. Commented Sep 17, 2010 at 23:11

1 Answer 1

1

I normally put this in the beforeFilter function of my app_controller.php file:

if ($this->RequestHandler->isAjax()) Configure::write('debug', 0);

See if that helps.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.