0

Hi,

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.

-SK

2
Contributors
1
Reply
2
Views
7 Years
Discussion Span
Last Post by scrappedcola
0

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.

mysite.com/index.php?parameter[]=1&parameter[]=2&parameter[]=5&parameter[]=3

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