How to receive an ajax post with a controller

I’ve got the problem, that I’ve got one site with lots of content in it with the visablity managed by javascript. In this site are some fields and stuff, which should end in a create for the table “statistic”.

So my question is, how can I manage a create on a table (or receive an ajax post with a controller) from a javascript file.

For example:


$.post("test.php", { name: "John", time: "2pm" } );

this post I want to "catch" in the StatisticController.

Thanks in advance

create new Route

example

‘test.php’ => ‘statistic/index’,

Sorry, i don’t really understand. Could you explain this on an example for me please? … sorry, still new to Yii :wink:

http://www.yiiframework.com/doc/api/1.1/CUrlManager

check this guide section you should be using createUrl to generate the correct url to your StatisticController instead of just calling a static php file (test.php)

You can also take a look at this wiki as it explains how to use this rules to generate user friendly urls

This wiki sends a $.ajax post to the controller:

http://www.yiiframework.com/wiki/323/dynamic-parent-and-child-cgridciew-on-single-view-using-ajax-to-update-child-gridview-via-controller-with-many_many-relation-after-row-in-parent-gridview-was-clicked/