How do you pass an array to the server side.
How do you pass an array to the server side.
I have tried passing an an array to the server like this:
o.data.business_contact.first_name = ["Saab", "Volvo", "BMW"];
I am getting an error notice: Array to string conversion. Is there a way to pass an array to the editor server side?
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
The error you are getting suggests that the array is being sent to the server, but that the server is trying to set it in the database as a string. Would that be correct? What do you actually want to do with it?
Allan
i want to now process the array by looping over its entries.
Unless you use the
Join
class, you would need to add some custom code to perform that loop and do whatever data processing you need.Allan
Maybe this is the answer:
use JSON.stringify(array) to encode your array in JavaScript, and then use $array=json_decode($_POST['jsondata']); in your PHP script to retrieve it.
That would certainly be one option. Exactly how that is done will likely depend upon the exact implementation requirements!
Allan