{"id":13,"date":"2012-03-26T09:16:58","date_gmt":"2012-03-26T06:16:58","guid":{"rendered":"http:\/\/antyat.ru\/?p=13"},"modified":"2012-04-07T20:39:28","modified_gmt":"2012-04-07T17:39:28","slug":"%d0%9a%d0%b0%d0%ba-%d1%80%d0%b0%d0%b1%d0%be%d1%82%d0%b0%d0%b5%d1%82-ajax-%d0%b2-cakephp-2-%d0%bf%d0%be-%d1%81%d1%80%d0%b0%d0%b2%d0%bd%d0%b5%d0%bd%d0%b8%d1%8e-%d1%81-cakephp-1-2","status":"publish","type":"post","link":"http:\/\/antyat.ru\/?p=13","title":{"rendered":"\u041a\u0430\u043a \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 Ajax \u0432 CakePHP 2 \u043f\u043e \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044e \u0441 CakePHP 1.2; Ajax in CakePHP 2 instead of CakePHP 1.2"},"content":{"rendered":"<p>\u0418 \u0442\u0430\u043a, \u043a\u0430\u043a \u0432 cakephp 1.2 \u043c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0441 ajax &#8212; \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435 \u0432\u044b\u043f\u0430\u0434\u0430\u044e\u0449\u0438\u0445 \u0441\u043f\u0438\u0441\u043a\u043e\u0432.<\/p>\n<p>\u041c\u044b \u0438\u043c\u0435\u0435\u043c \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u0438 (professions) \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0435\u0441\u0442\u044c \u043a\u0443\u0440\u0441\u044b (courses). \u0417\u0430\u0434\u0430\u0447\u0430 \u043f\u0440\u0438 \u0432\u044b\u0431\u043e\u0440\u0435 \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u043e\u0431\u043d\u043e\u0432\u0438\u0442\u044c \u0432\u044b\u043f\u0430\u0434\u0430\u044e\u0449\u0438\u0439 \u0441\u043f\u0438\u0441\u043e\u043a \u0441 \u043d\u0443\u0436\u043d\u044b\u043c\u0438 \u043a\u0443\u0440\u0441\u0430\u043c\u0438.<\/p>\n<p>\u041a\u0430\u043a\u0438\u0435 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u043d\u0435 \u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0432 \u043f\u0435\u0440\u0432\u0443\u044e \u043e\u0447\u0435\u0440\u0435\u0434\u044c:<\/p>\n<p>\u0432 \u043b\u0435\u0439\u0430\u0443\u0442\u0435 &#8212; \u0432\u044b\u0432\u0435\u0441\u0442\u0438 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u043a\u0430\u043a\u043e\u0433\u043e \u043b\u0438\u0431\u043e JS \u0434\u0432\u0438\u0436\u043a\u0430 (Prototype \u0438\u043b\u0438 Jquery):<\/p>\n<pre style=\"padding-left: 30px;\">echo $javascript-&gt;link(array('prototype'));<\/pre>\n<p>\u0432 app_controller &#8212; \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u043d\u0443\u0436\u043d\u044b\u0445 \u0445\u0435\u043b\u043f\u0435\u0440\u043e\u0432 (\u043f\u0440\u0438\u0447\u0435\u043c <strong>\u043f\u043e\u0440\u044f\u0434\u043e\u043a \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u0445\u0435\u043b\u043f\u0435\u0440\u043e\u0432 \u043d\u0435 \u0432\u0430\u0436\u0435\u043d<\/strong>):<\/p>\n<pre style=\"padding-left: 30px;\">var $helpers = array('Html', 'Form', \u00a0'Ajax','Javascript');<\/pre>\n<p>\u0427\u0442\u043e \u043d\u0443\u0436\u043d\u043e \u0432\u0434\u0435\u043b\u0430\u0442\u044c \u0432 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0435 (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 students_controller.php) (\u043c\u043e\u0434\u0435\u043b\u044c Student) \u0434\u043b\u044f \u0432\u044b\u0432\u043e\u0434\u0430 \u0441\u0442\u0443\u0434\u0435\u043d\u0442\u043e\u0432 \u043e\u0434\u043d\u043e\u0433\u043e \u043a\u0443\u0440\u0441\u0430:<\/p>\n<p>\u0432\u044b\u0431\u0438\u0440\u0430\u0435\u043c \u0432\u0441\u0435 \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u0438 \u0432\u044b\u0432\u043e\u0434\u0438\u043c \u0438\u0445 \u0432 \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u0441\u043f\u0438\u0441\u043e\u043a<\/p>\n<pre>\u00a0function index () {<\/pre>\n<pre style=\"padding-left: 60px;\">$this-&gt;loadModel('Profession');\r\n$professions = $this-&gt;Profession-&gt;find('list');\r\n$this-&gt;set(compact('professions'));<\/pre>\n<pre>}<\/pre>\n<pre>\u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u043c\u0430\u044f \u0441\u043e \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u043e \u0447\u0435\u0440\u0435\u0437 AJAX<\/pre>\n<pre>function update_course () {\r\n if(!empty($this-&gt;data['Student']['profession_id'])) {\r\n $profession_id = $this-&gt;data['Student']['profession_id'];\r\n $this-&gt;loadModel('Course');\r\n $options = $this-&gt;Course-&gt;find('list', array('conditions' =&gt; array ('Course.profession_id' =&gt; $profession_id)));\r\n $this-&gt;set(compact('options'));\r\n }<\/pre>\n<p style=\"padding-left: 30px;\">\u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0435 \u0432\u044c\u044e\u0448\u043a\u0438 update_course<\/p>\n<pre>&lt;?php\r\nif(!empty($options)) {\r\n echo \"&lt;option value=''&gt;\u0412\u044b\u0431\u0435\u0440\u0438\u0442\u0435 \u043a\u0443\u0440\u0441&lt;\/option&gt;\";\r\n foreach($options as $k =&gt; $v) {\r\n echo \"&lt;option value='$k'&gt;$v&lt;\/option&gt;\";\r\n }\r\n}\r\n?&gt;<\/pre>\n<p style=\"padding-left: 30px;\">\u0447\u0442\u043e \u043d\u0443\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0432\u043e \u0432\u044c\u044e\u0448\u043a\u0435 index&#8230;<\/p>\n<p style=\"padding-left: 30px;\">\u0432\u044b\u0432\u043e\u0434\u0438\u043c \u0441\u043f\u0438\u0441\u043e\u043a \u0444\u0430\u043a\u0443\u043b\u044c\u0442\u0435\u0442\u043e\u0432&#8230; \u043e\u0441\u043e\u0431\u043e\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u043d\u0430 \u0432\u044b\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0439 \u0436\u0438\u0440\u043d\u044b\u043c \u0442\u0435\u043a\u0441\u0442\u043e\u043c \u043a\u0443\u0441\u043e\u043a \u043a\u043e\u0434\u0430.<\/p>\n<pre>&lt;div&gt;\r\n &lt;?php\r\n echo $form-&gt;input('profession_id', array('options' =&gt; $professions, 'empty' =&gt; '\u0412\u044b\u0431\u0435\u0440\u0438\u0442\u0435 \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u044c', 'label' =&gt; '', <strong>'id' =&gt; 'professions'<\/strong>), null);\r\n ?&gt;\r\n &lt;\/div&gt;<\/pre>\n<p>\u0442\u0435\u043f\u0435\u0440\u044c \u043a\u0430\u043a \u0444\u043e\u0440\u043c\u0438\u0440\u0443\u0435\u0442\u0441\u044f courses<\/p>\n<pre>&lt;div&gt;\r\n &lt;?php\r\n echo $form-&gt;select('course_id', array(), null, array('id' =&gt; 'courses'));\r\n $course_options = array('url' =&gt; 'update_course','update' =&gt; 'courses');\r\n echo $ajax-&gt;observeField('professions', $course_options);\r\n ?&gt;\r\n &lt;\/div&gt;<\/pre>\n<p>\u0421\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0432\u0441\u0435!!! \u0422\u0430\u043a \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0430\u0432\u0442\u043e\u043c\u0430\u0433\u0438\u044f cakephp 1.2. \u041e\u0434\u043d\u0430\u043a\u043e \u043d\u0435 \u0432\u0441\u0435 \u0442\u0430\u043a \u043f\u0440\u043e\u0441\u0442\u043e \u0435\u0441\u043b\u0438 \u043c\u044b \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043d\u0430 CakePHP 2.? (\u043f\u043e\u043a\u0430 \u0440\u0430\u0431\u043e\u0442\u0430\u044e \u0441 2.0 )<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u0418 \u0442\u0430\u043a, \u043a\u0430\u043a \u0432 cakephp 1.2 \u043c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0441 ajax &#8212; \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435 \u0432\u044b\u043f\u0430\u0434\u0430\u044e\u0449\u0438\u0445 \u0441\u043f\u0438\u0441\u043a\u043e\u0432. \u041c\u044b \u0438\u043c\u0435\u0435\u043c \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u0438 (professions) \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0435\u0441\u0442\u044c \u043a\u0443\u0440\u0441\u044b (courses). \u0417\u0430\u0434\u0430\u0447\u0430 \u043f\u0440\u0438 \u0432\u044b\u0431\u043e\u0440\u0435 \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u043e\u0431\u043d\u043e\u0432\u0438\u0442\u044c \u0432\u044b\u043f\u0430\u0434\u0430\u044e\u0449\u0438\u0439 \u0441\u043f\u0438\u0441\u043e\u043a \u0441 \u043d\u0443\u0436\u043d\u044b\u043c\u0438 \u043a\u0443\u0440\u0441\u0430\u043c\u0438. \u041a\u0430\u043a\u0438\u0435 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u043d\u0435 \u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0432 \u043f\u0435\u0440\u0432\u0443\u044e \u043e\u0447\u0435\u0440\u0435\u0434\u044c: \u0432 \u043b\u0435\u0439\u0430\u0443\u0442\u0435 &#8212; \u0432\u044b\u0432\u0435\u0441\u0442\u0438 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u043a\u0430\u043a\u043e\u0433\u043e \u043b\u0438\u0431\u043e JS \u0434\u0432\u0438\u0436\u043a\u0430 (Prototype \u0438\u043b\u0438 Jquery): [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-13","post","type-post","status-publish","format-standard","hentry","category-1"],"_links":{"self":[{"href":"http:\/\/antyat.ru\/index.php?rest_route=\/wp\/v2\/posts\/13","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/antyat.ru\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/antyat.ru\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/antyat.ru\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/antyat.ru\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=13"}],"version-history":[{"count":8,"href":"http:\/\/antyat.ru\/index.php?rest_route=\/wp\/v2\/posts\/13\/revisions"}],"predecessor-version":[{"id":33,"href":"http:\/\/antyat.ru\/index.php?rest_route=\/wp\/v2\/posts\/13\/revisions\/33"}],"wp:attachment":[{"href":"http:\/\/antyat.ru\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=13"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/antyat.ru\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=13"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/antyat.ru\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=13"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}