Yii Ajax问题

I've previously created a question where I wanted to understand principles of work with ajax in Yii. So, I'm trying to implement an answer. I'v created controller and placed in into controllers directory:

<?php
class AjaxController extends CController
{
    public function actionDoThing()
    {
        // Get request object
        $request = Yii::app()->request;

        // Check if request is acceptable
        if ($request->isPost && $request->isAjaxRequest)
        {
            echo CJSON::encode(array('hello'=>'world'));
        }
        // else
        // {
        //     throw new CHttpException(403);
        // }
    }
}
?> 

Also I have this fragment with script in my view.

<script>
$(document).on('click','div.lessonDiv', function() {
    $.ajax({
        type: "POST",
        url: <?php /*Also I tried just DoThing instead of actionDoThing, this doesn't work*/echo $this->createUrl('AjaxController/actionDoThing'); ?>,
        success: function(data, textStatus, jqXHR) 
        {
            console.log(data);
        }
    });
});
</script>

Dunno what's wrong, but console says:

Uncaught SyntaxError: Invalid flags supplied to RegExp constructor 'actionDoThing'

Where am I wrong now?

Looks like you forgot quotes around URL:

$.ajax({
    type: "POST",
    url: "<?php echo $this->createUrl('AjaxController/actionDoThing'); ?>",
    success: function(data, textStatus, jqXHR) {
        console.log(data);
    }
});

First of all

wrap the Js code inside

$(function{
// your code here
});

So your code will look like

 $(function(){
    $(document).on('click','div.lessonDiv', function() {
        $.ajax({
            type: "POST",
            url: "<?php echo $this->createUrl('AjaxController/actionDoThing'); ?>",
            success: function(data, textStatus, jqXHR) 
            {
                console.log(data);
            }
        });
    });

});

Second thing:

Change the AjaxController/actionDoThing to ajax/doThing

So your final code will be like

    $(function(){
    $(document).on('click','div.lessonDiv', function() {
        $.ajax({
            type: "POST",
            url: "<?php echo $this->createUrl('ajax/doThing'); ?>",
            success: function(data, textStatus, jqXHR) 
            {
                console.log(data);
            }
        });
    });

});