killboy Posted May 29, 2008 Share Posted May 29, 2008 Hi there.Can anyone tell me how to send an array with AJAX?For example, I have <input type="text" name="modulo[]"> I want to send the values when I get a collection by the getElementsByName property.Thanks for the help. Link to comment Share on other sites More sharing options...
jesh Posted May 29, 2008 Share Posted May 29, 2008 I believe you can only send string data through an HTTP request. So, if you want to send an array, you'll have to serialize it into a string first and then deserialize it on the server to turn it back into an array.One easy way with arrays is to join the elements into a comma-delimited string and then, on the server, split the string on the commas back into an array. Link to comment Share on other sites More sharing options...
justsomeguy Posted May 29, 2008 Share Posted May 29, 2008 You can also convert it to JSON. There's code for a class here that has a method called stringify that turns an object into JSON text:http://www.json.org/json2.js Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.