Passing url as parameter from view to controller |
[eluser]bibos[/eluser]
Hi, I'm trying passing an URL as parameter from view to controller: In my view i have JavaScript code using Ajax to send an URL to a Controller Method , But i have no idea haw to do this stuf! Code: $.get("desck/getContent/url/" + url[0], function (response) { the code above dosent work becose the URL contain "/". Can some one help me do it? THKS
[eluser]bibos[/eluser]
Hi, what i'm looking for is some thing similar to : Code: ... THKS
[eluser]Iszuddin Ismail[/eluser]
in your controller, you can use the $this->uri->segment(x). consider the following example Code: $a = $this->uri->segment(1); // should get desck, your controler
[eluser]bibos[/eluser]
Hi, Théorically it should do like that, but dont forget that a url is composed like : Code: http://mysite.com so : Code: $d = $this->uri->segment(4); return : Code: http that's why i have some truble to deal with this case. THKS
[eluser]Jason Stanley[/eluser]
This example: Code: $.get("desck/getContent/url/" + url[0], function (response) { It doesn't work because url[0] contains a slash right? In this situation you should use encodeURIComponent. It works a bit like urlencode for php. Code: $.get("desck/getContent/url/" + encodeURIComponent(url[0]), function (response) { http://www.w3schools.com/jsref/jsref_enc...ponent.asp
[eluser]Iszuddin Ismail[/eluser]
What if you use jquery's $.post then and send the data as post value? And you can use $this->input->post('url'); http://api.jquery.com/jQuery.post/ |
Welcome Guest, Not a member yet? Register Sign In |