Undesired URL after running Javascript |
[eluser]cinewbie81[/eluser]
Hi all, I have a image button with POST method = 'customer/action' - as shown following Code: <?php echo form_open('customer/action'); ?> Here's my ExecuteEdit() javascript Code: function ExecuteEdit() My question is: When i click on that image button, it return me the url www.mysite.com/customer/action. I want something like www.mysite.com/customer/action?d=7&sid=0.3104892969145657 .. Anyone ?
[eluser]tonanbarbarian[/eluser]
you would be better off creating the link as something like the following www.mysite.com/customer/action/d/7/sid/0.3104892969145657 then use something like the following in your controller Code: $params = $this->uri->uri_to_assoc(3); this will produce an array of name value pairs like this Code: [array] I have not personally used this yet but this is what the user guide says Look under the URI Class for more information Basically CI does not like ?x=y&a=b in the url. You can change the config to allow it in config.php file by setting the following Code: $config['enable_query_strings'] = true; but then all of your urls would be www.mysite.com/index.php?c=customer&m=action&d=7&sid=0.3104892969145657 personally I prefer the cleaner CI urls
[eluser]cinewbie81[/eluser]
Hi tonanbarbarian, I guess you misunderstood me. The problem now is in my ExecuteEdit() javascript function, when i set parent.location = mywebsiteurl + "customer/action" +"?d="+editKey+"&sid;="+Math.random();, it seems to me that it doesn't take effect on the url .. why is that so ??
[eluser]coolfactor[/eluser]
Everything after the "?" is not part of the url.. they are url arguments. How are you testing this?
[eluser]cinewbie81[/eluser]
Hi, Ignore the ”?d="+editKey+"&sid;="+Math.random() part .. Now, even though i set parent.location = mywebsiteurl + “customer/another_action” , it will still return me back to www.mywebsite.com/customer/action instead of www.mywebsite.com/customer/another_action .. i doubt it has something to do with form_open('customer/action') as shown in code above .. i could be wrong though
[eluser]coolfactor[/eluser]
What exactly does the mywebiteurl variable contain?
[eluser]cinewbie81[/eluser]
mywebsiteurl variable is actually base_url() .. when i alert it it will return me "www.mywebsite.com" ..
[eluser]coolfactor[/eluser]
Probably a good idea to have it start with http://
[eluser]cinewbie81[/eluser]
It's the same ... see, even if i change parent.location.url to http://yahoo.com , it also go to www.mywebsite.com/customer/action
[eluser]coolfactor[/eluser]
Not sure if it makes any difference, but I always use window(dot)location, not parent.location. But then again, I never build framed sites. (I wasn't able to type it out normally in this forum post) |
Welcome Guest, Not a member yet? Register Sign In |