I have to send a 2-dimensional array (along with several other variables) to PHP using jQuery.ajax(). I believe my options are:
- Serialize to json with JSON-js
- Send both arrays as csv strings and recompile on the other side.
My questions are:
A. Is there anything wrong with option #2 if I'd prefer not to include another library for a small function? B. Are there other options besides options #1 and #2?
Thanks!
.serializeArrayfunction to serialize the JavaScript array and PHP'sjson_decodeto decode it?.serializeArray...the name would suggest it's exactly what I'm looking for. I looked at the link you provided and it seems that it takes$(":input")or$('form')and returns an array with the name and values of the form elements. So (if I were using a form) it leaves me with the same problem I had before, unfortunately. But thanks for the link - good to know it exists!