php - How can I post a 2D JavaScript array to the server? -
i have array, mydata=[[1,2,3],[4,5,6],....,[..,..,..]] want post server.
usually, js variable, set variable textbox , submit form using js. however, when set 2d array textbox, js converts string, such becomes 1d array, looks like: [1,2,3,4,5,6....]
i want able post entire 2d array server , retrieve on next page using php. how do that?
thanks!
you should utilize json turn array string javascript , parse string array in php.
for example:
var mydata = var info = [['hooray',1],['test','meow'],[0,3,2]]; var mydata_string = json.stringify(mydata);
this turn object/array string can post , parse php so:
$mydata = json_decode($input);
references:
json (javascript)
json_decode() (php)
php javascript jquery
No comments:
Post a Comment