Pubblicazione di un array usando jQuery .post ()
Domanda
Quindi sono piuttosto nuovo per l'intero .post () esperienza con jquery.
Ho solo esperienza di pubblicazione dei valori di input finora.Quello che voglio fare è pubblicare un array.
Quale è una serie standard di un elenco di numeri.L'obiettivo finale: eseguire una query con questi valori.
Qualcuno potrebbe spiegarmi in pratica come usare jquery .post () posso pubblicare il mio array?
Molte grazie,
Soluzione
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
Altri suggerimenti
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()