render partial

Ive been looking around for an answer but cant seem to find one

I’m trying to use AJAX to populate a message in one of my views.

here is what I have for code

in my EventController.php I have this

class eventController extends Controller{



    public function actionSchedule()


	$data = array();

        $data["myfiles"] = "File listing";



    public function actionUpdateajax($file)



	$data = array();

        $data["myfiles"] = "Files modified with AJAX";

        $this->renderPartial('_ajaxcontent', $data, false, true);






Now I n my view file (schedule.php) I have

 <div id="data">

   <?php $this->renderPartial('_ajaxcontent', array('myfiles'=>$myfiles)); ?>


  <?php echo CHtml::ajaxButton ("Update data",


                              array('update' => '#data'));


and in the same view directory I have a file called _ajaxcontent.php with the following content

<?php echo $myfiles; ?>

now if I go to my link

mysite/index.php?r=event/schedule it works I see the content "File listing" but when I click on the button it does not give me the content set in actionUpdateajax. am I missing something?

I took this from this wiki

the main diff is that my eventController class extends Controller and not CController. is this why?

Have you checked that you comply with that note:

This could be this, or your url routes are messing with your call.

Can you check:


[*]That you can access your other action normally through the browser (at a later stage, when everything works, you may want to process only if it’s an ajax request, just saying)

[*]In Firebug, when monitoring XHR, is the ajax call fired? What’s the actually called url? What’s the return code? If it’s an error, what is it?


no access rules for that model

for the rest, I’ll check later tonight…

how do you check for Ajax in firebug?

Hmm I use Safari (so no Firebug), but it should be easy… Open Firebug, look into Network or XHR tab before clicking on the link. Then upon click, it should show up.

ok, got the XHR tab in firebug (very cool)…anyway, when I hit my ajax button it gives a status of

400 CHttpException

the url gives me this


that _=1346992593970 looks kind of odd…not sure what that is.

haha…found the bug! in my update function I had this

public function actionUpdateAjax($file)

but I was not passing a file…so because of that it kept crapping out!

so now this works

   public function actionUpdateajax()



        $data = array();

        $data["myfiles"] = "Files modified with AJAX";

        $this->renderPartial('_ajaxcontent', $data, false, true);




Glad you solved it.