Let's say I have a javascript array with a bunch of elements (anywhere from 50-200).
I want to send that to PHP (prepared statement) using ajax. Currently, I .load
a php file many times inside of a loop, but I want to convert that into an array and send the array once, loading the PHP file once instead of 50-200 times.
array[i] = variable;
You could use
JSON.stringify(array)
to encode your array in JavaScript, and then use$array=json_decode($_POST['jsondata']);
in your PHP script to retrieve it.