Cakephp ajax not working properly

I am new to cakephp and I want to implement Ajax on my homepage.

I have three modules on my page (client, developer and project). I want to add ajax link. It only works fine on the index page.

My code is:

<h2>Projects</h2> <div class="clear"></div> <ul> <li title="Project List"> <?php echo $ajax->link('Projects List', array("controller" => "projects", "action" => "index"), array( 'update' => 'main_page' ));?> </li><br /> <li title="Add New Project"> <?php echo $ajax->link('Add New Project', array("controller" => "projects", "action" => "add"), array( 'update' => 'main_page' ));?> </li> </ul> 

Now my first problem is that on the add form, checking with js does not work.

Secondly: if I use the built-in cakephp validation, then it validates my form, but redirects the page to "admin / projects / add" if the data is not inserted.

The third problem is that when the above case happens, and I want to redirect to the list page via my ajax link, at that time it also does not work.

+6
source share
1 answer

It is best to stop using the ajax helper. It has been discounted and will not be available in branch 3.x.

This was done because it was not very useful to start, very restrictive and erroneous.

ajax with something like jQuery is not very difficult, and you better learn it or a similar tool.

+1
source

Source: https://habr.com/ru/post/916880/


All Articles