Post JS Array to PHP

diabolo

Community Advocate
Community Support
Messages
1,682
Reaction score
32
Points
48
I've googled this up already, but everything is very confusing for me. (I totally fail at JS)

I have an array in JS, and I need to get it to PHP to process and dump the information into the database.
 

misson

Community Paragon
Community Support
Messages
2,572
Reaction score
72
Points
48
What type of data? The answer will affect the generality of the solution.
 

diabolo

Community Advocate
Community Support
Messages
1,682
Reaction score
32
Points
48
Code:
# dpGetSelected( ) returns Array
Gets a list of Dates currently selected by this datePicker. This will be an empty array if no dates are currently selected or NULL if there is no datePicker associated with the matched element.
Example:

Will alert an empty array (as nothing is selected yet)

$('.date-picker').datePicker();
alert($('.date-picker').dpGetSelected());

http://www.kelvinluck.com/assets/jquery/datePicker/v2/demo/documentation.html
 

xav0989

Community Public Relation
Community Support
Messages
4,467
Reaction score
95
Points
0
I don't get Step 4 where you have to split the string back to an array in PHP, they don't say how.

The fourth part is quite easy to write (I wrote it myself):

PHP:
<?php

$data = $_POST['arv']; //you need to sanitize it, though

$array = explode(",", $data);

?>
 
Last edited:
Top