posting an array using JQuery .post()
Question
so I am rather new to the whole .post() experience with jquery.
I have only experience POSTing input values so far. What I want to do is POST an array.
which is a standard array of a list of numbers. The end goal being: performing a query with these values.
Could somebody explain to me very basically how using JQuery .post() I can post my array?
many thanks,
Solution
I guess, without going into great detail, the answer on you question is called JSON
.
The process is easy:
Backend (PHP) Array -> encode as JSON string -> send that JSON string to the browser -> decode the JSON string as Javascript Array
OTHER TIPS
Check jQuery.post(). There is an example for posting arrays.
EDITED: Example is like;
$.post("test.php", { 'choices[]': ["Jon", "Susan"] });
Check The jQuery Site and the Docs for jQuery.post()