Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

cakephp ajax not working properly

I am new in cakephp and I want to implement Ajax on my home page.

I have three modules in my page (client, developer and project). I want to add an ajax link. It's working perfectly only in the index page.

My code:

<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 issue is that in the add form, the validation with js is not working.

Second is: if I use cakephp inbuilt validation then it validates my form but redirects the page to "admin/projects/add" if no data is inserted.

Third problem is that when the above case happens and I want to redirect to listing page through my ajax link, at that time its also not working.

like image 343
deck john Avatar asked May 29 '12 06:05

deck john


1 Answers

The best thing to do is stop using the ajax helper. Its been depreciated and will not be available in the 3.x branch.

This was done because it was not a good idea to start with, very limiting and buggy.

ajax with something like jQuery is not very difficult and you should rather look into using that or a similar tool.

like image 198
dogmatic69 Avatar answered Sep 28 '22 09:09

dogmatic69