![]() |
How to get the url segment from jQuery - 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: How to get the url segment from jQuery (/showthread.php?tid=17057) |
How to get the url segment from jQuery - El Forum - 03-24-2009 [eluser]Jose Dueñas[/eluser] Hi, I'm developing a CodeIgniter + jQuery application. I'd need to get the url segment to save as a javascript variable. I want to do something like that (in the view): Code: var MyJavascriptVar = $this->uri->segment(3); How could I do that? Thanks, Jose How to get the url segment from jQuery - El Forum - 03-24-2009 [eluser]TheFuzzy0ne[/eluser] One thing I'd probably go for would be to insert the segment value into the script itself with an echo statement. If not, something like this might work: Code: function getSegment(num) { The above code is untested. How to get the url segment from jQuery - El Forum - 03-24-2009 [eluser]Jay Turley[/eluser] If I'm not misunderstanding couldn't you do this? Code: <script type="text/javascript"> How to get the url segment from jQuery - El Forum - 03-24-2009 [eluser]bretticus[/eluser] A quick google query yielded this jQuery plugin: http://projects.allmarkedup.com/jquery_url_parser/ How to get the url segment from jQuery - El Forum - 03-24-2009 [eluser]Jose Dueñas[/eluser] Thanks folks for your help. It seems very useful for me this url parser, bretticus. Regards, Jose |