Opening a new page w/ dynamic data |
(03-05-2017, 11:48 PM)Wouter60 Wrote: It's all because CI expects URL's to have at least 2 segments: controller and method. If the second segment is omitted, the controller will execute the index method by default. Thanks for your patience. This is really helpful. Re: Code: c_tunesheet/edit //means: open then c_tunesheet controller and find the edit method inside it Yes, I see now that of course using url segments to pass data I can't leave out the function name 'index' and expect CI to know that I wanted the default index function. And therefore: The command Code: window.open("<?= site_url('c_tunesheet/');?>"+tuneID,'_blank'); You said, "This should work:" Code: window.open("<?= site_url('c_tunesheet/index');?>"+tuneID,'_blank'); Yes, but still I get that error: Code: Access forbidden! However, if I use: Code: window.open('c_tunesheet/index/'+tuneID,'_blank'); The code works as you suggest it should. The new page url now appears as: http://localhost/CID17/c_tunesheet/index/1632 . . . and the content appears correctly as: Code: c_tunesheet controller says: Tune ID: 1632 I don't know why using site_url() produces that error but I'll try to figure that out as a separate issue. Thanks again for your help.
Wouter60 made a little misstake
It missing a / Code: window.open("<?= site_url('c_tunesheet/index/');?>"+tuneID,'_blank');
Very confusing.
If I use base_url() . 'controller/method', the function base_url() itself ends with a / (03-06-2017, 11:34 AM)Paradinight Wrote: Wouter60 made a little misstake When I try . . Code: window.open("<?= site_url('c_tunesheet/index/');?>"+tuneID,'_blank'); Damn, for a while I couldn't figure out how to turn on Code formatting. Now I can't shut it off.
(03-06-2017, 12:11 PM)codeguy Wrote:(03-06-2017, 11:34 AM)Paradinight Wrote: Wouter60 made a little misstake php in js is a bad idea make in the <head></head> of you document a Code: <script> in you js fie Code: window.open(base_url+"c_tunesheet/index/"+tuneID,'_blank'); (03-06-2017, 01:19 PM)Paradinight Wrote:(03-06-2017, 12:11 PM)codeguy Wrote:(03-06-2017, 11:34 AM)Paradinight Wrote: Wouter60 made a little misstake OK I got it running now. I couldn't get the <script> inside the doc <head> to work for some reason so I created a hidden div at the top of the main page . . <div id="hiddenDiv"><?=base_url()?></div> Then I used this in the js event function callback . . . var base_url=$('#hiddenDiv').text(); window.open(base_url+'c_tunesheet/index/'+tuneID,'_blank'); Do you think this a less elegant (or bad practices) solution? |
Welcome Guest, Not a member yet? Register Sign In |