Welcome Guest, Not a member yet? Register   Sign In
Onclick does nothing
#7

There's one more thing you need to know about AJAX related to CodeIgniter.
In your Javascript (hopefully jQuery), one of the arguments is the "url".
You should set it to site_url(), with your controller/method between the brackets.

Example:
PHP Code:
url "<?= site_url('controllername/methodename');?>"

This seems odd, because now you're doing server sided stuff inside a Javascript!
But all the php code does, is injecting the complete url into your Javascript when the page is rendered, so your Javascript knows what url to call once the js function is executed.
Mind that <?= is short for: <?php echo
Reply


Messages In This Thread
Onclick does nothing - by Deborah - 05-13-2019, 09:17 AM
RE: Onclick does nothing - by ciadmin - 05-13-2019, 09:41 AM
RE: Onclick does nothing - by albertleao - 05-13-2019, 09:58 AM
RE: Onclick does nothing - by Deborah - 05-13-2019, 10:58 AM
RE: Onclick does nothing - by donpwinston - 05-13-2019, 03:25 PM
RE: Onclick does nothing - by albertleao - 05-13-2019, 03:33 PM
RE: Onclick does nothing - by Wouter60 - 05-13-2019, 11:10 PM
RE: Onclick does nothing - by albertleao - 05-14-2019, 10:52 AM
RE: Onclick does nothing - by Deborah - 05-16-2019, 10:31 AM
RE: Onclick does nothing - by albertleao - 05-16-2019, 12:02 PM
RE: Onclick does nothing - by Deborah - 05-16-2019, 01:28 PM
RE: Onclick does nothing - by albertleao - 05-17-2019, 07:01 AM
RE: Onclick does nothing - by Deborah - 05-17-2019, 07:20 AM
RE: Onclick does nothing - by shivambhatele - 06-23-2019, 09:43 PM
RE: Onclick does nothing - by MattZand - 09-17-2019, 02:44 PM
RE: Onclick does nothing - by InsiteFX - 07-04-2021, 02:21 AM



Theme © iAndrew 2016 - Forum software by © MyBB