CodeIgniter Forums
PHP Code in jQuery file - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: PHP Code in jQuery file (/showthread.php?tid=46400)



PHP Code in jQuery file - El Forum - 10-30-2011

[eluser]Mr.Data[/eluser]
Hello!
I am using a seperate js-file with jQuery code. At a certain point I would like to place this code:
Code:
$.post("<?= site_url('home/add') ?>", $("#form_id").serialize(), function(phpData) {
You see that there is the Codeigniter site_url() function but unfortunately you cannot use php code in a js-file. Of course I could just hardcode my site url at that place but isn't there a workaround so that I can still use Codeigniter's functions? What do you do when you have such a problem?