Code Igniter - Anchor Reutrn False?
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', 'Cli开发者_开发问答ents', array('onclick'=> "content_ajax_client()")); ?> </li>
Thanks
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...
Alternatively to Robimp's answer, you could return false inside your js function.
function content_ajax_client(){
//your code here
return false;
}
精彩评论