How to pass an array to a controller?

[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.

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!

Actually, you can just use precisely what you were saying with a touch of work -

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.

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 ?

cant you just add the + to the permitted uri characters setting in the config?

I'm a newbie here, never thought about that. This works! Thanks!

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.