views:

32

answers:

2

Hello,

I'm trying to return false with using the anchor function in CI, as it's sending me to another page, rather than loading ajax.

Here's my code:

<li id="addclient"><?php echo anchor('site_add_client', 'Clients', array('onclick'=> "content_ajax_client()")); ?>  </li>

Thanks

+1  A: 

Just add return false in with the onclick...

<?php echo anchor('site_add_client', 'Clients', array('onclick'=> "content_ajax_client(); return false")); ?>  </li>

Et voila...

Robimp
+1  A: 

Alternatively to Robimp's answer, you could return false inside your js function.

function content_ajax_client(){
    //your code here
    return false;
}
kevtrout
Ah good thinking Kevtrout, that hadn't occurred to me!
Robimp