![]() |
How to point to a controlle from a js file? - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21) +--- Thread: How to point to a controlle from a js file? (/showthread.php?tid=26883) |
How to point to a controlle from a js file? - El Forum - 01-26-2010 [eluser]chefnelone[/eluser] Hello. I'm doing a ajax call (using jquery) from a js file like this: Code: $.post("http://www.mysite.com/site/order", order, function(theResponse)... where site is the controller and order is the method Is there any way to point the controller with this line: Code: $.post("site/order", order, function(theResponse)... or should I use <?php echo base_url(); ?> in the js file as well? How to point to a controlle from a js file? - El Forum - 01-26-2010 [eluser]Dyllon[/eluser] I like to define my base URI, module/controller, and method in my view header so I can use them in any javascripts. Code: var BASE_URI = "<?php echo base_url(); ?>"; Then use the variables in your javascript Code: $.post(BASE_URI + CI_CONTROLLER + '/' + CI_METHOD, order, function(theResponse)... How to point to a controlle from a js file? - El Forum - 01-27-2010 [eluser]chefnelone[/eluser] [quote author="Dyllon" date="1264549311"]I like to define my base URI, module/controller, and method in my view header so I can use them in any javascripts. Code: var BASE_URI = "<?php echo base_url(); ?>"; Then use the variables in your javascript Code: $.post(BASE_URI + CI_CONTROLLER + '/' + CI_METHOD, order, function(theResponse)... I had already found a solution, but I'll try your idea as well thanks. How to point to a controlle from a js file? - El Forum - 02-15-2010 [eluser]Haqqi[/eluser] [quote author="chefnelone" date="1264614088"][quote author="Dyllon" date="1264549311"]I like to define my base URI, module/controller, and method in my view header so I can use them in any javascripts. Code: var BASE_URI = "<?php echo base_url(); ?>"; Then use the variables in your javascript Code: $.post(BASE_URI + CI_CONTROLLER + '/' + CI_METHOD, order, function(theResponse)... I had already found a solution, but I'll try your idea as well thanks.[/quote] Can you provide your solution too?? |