Welcome Guest, Not a member yet? Register   Sign In
How to pass an array to a controller?
#11

[eluser]Boris Strahija[/eluser]
If it has to be client-side (JS), without cookies, then I think the only sollution is submiting a form via POST.
Putting all that data in the URL is a bad idea in my oppinion.

You could do it with AJAX also. A combination of AJAX and CI sessions would be nice. I recently did something like that when I was building an csv exporter for html tables. Take a look at JQuery, it's really simple to use.
#12

[eluser]gminuses[/eluser]
Yes, I'm using jQuery to make ajax calls. I figure I will have to make a post request whenever passing an array is needed then. Thank you for your replies!
#13

[eluser]BrianDHall[/eluser]
Actually, you can just use precisely what you were saying with a touch of work - mysite.com/controller/function/var1/var2/var3/var4/array_1_2_3_4_5_6

Then you can look through the URI segments in your controller, and if one of the parameters provided contains "array_" at the very beginning then you can run a simple explode() on it. The first element will of course be 'array', but you can pop that off after exploding or remove it from the string before that.
#14

[eluser]gminuses[/eluser]
This is better! But still not neat enough. Is it possible to use a hook or a library or something to make codeigniter accept "+" that I can split the string on ?
#15

[eluser]CroNiX[/eluser]
cant you just add the + to the permitted uri characters setting in the config?
#16

[eluser]gminuses[/eluser]
I'm a newbie here, never thought about that. This works! Thanks!




Theme © iAndrew 2016 - Forum software by © MyBB