0

I have 2 functions in "events" (index, event_ajax)controller in my cakephp(2.5) web site. I'm trying to load HTML block to 'index.ctp' page by calling to 'event_ajax' function using ajax. When I call to this function it shows nothing. Look at 'net' tab in firebug it shows internal server error and 'net'->'Response' tab I can see whole layout is loaded.

I'm little confuse about in this scenario, can any one give a little explanation for following questions??? thanks in advance :)

  1. Is it possible to call actions in same controller using ajax function ??
  2. How 'Response' tab shows layout when '$this->layout' is set to NULL ??
  3. when type url 'example.com/events/event_ajax', output data still '$this->autoRender=false'. how can this happen ??

this is my 'event_ajax' action.

   public function event_ajax($x=1) {
        $this->layout       =   NULL;
        $this->autoRender   =   false ; 
        $contName           = $this->Page->conName($x);
        $latestContEvents    = $this->Page->latestContEvent($x);

        $internal   =   '';
        if (!empty($latestContEvents)){ 
          foreach ($latestContEvents AS $latestContEvent){ 
                $internal   .=   '<li class="pull-left"> <div class="content-wrapper">'..... //do something                  
        }
        else {
            $internal   =   '<p>&nbsp;&nbsp;&nbsp; No events found for this continent</p>';          
        }

        $ContEvents =   '<div class="carousel events-location-carousel">'.$internal.'</div> ';

        return $ContEvents; 
       // return json_encode($ContEvents);

    }

1 Answer 1

0

Try with

$this->layout = 'ajax';
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.