I have a javascript array that contains only integers.I need to pass this array via AJAX as a variable. How do I convert a javascript array to a variable so that I can pass it via AJAX.

On the receiving php page how do I convert back the var to an php array. I tried searching through forums for a solution but couldn't find any. Any help will be greatly appreciated. Thank you all in advance for your reply.


7 Years
Discussion Span
Last Post by scrappedcola

well a possibly ugly way would be to convert your array to a string that is delimited by some character (the pipe or | is usually a good choice), then when you grab that var it's just a matter of splitting the string again. Or you can just pass the array check out this page: http://www.captain.at/howto-parameter-array-in-php.php Basically you just put [] at the end of the variable name in the url.


(can find more results by googling "send array to php" or "post array to php"

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.