0

Pass JavaScript array to Php page?

Hello, is it possible To pass a JavaScript array To PHP page ? if it ils, how ? Thanks

25th Jan 2017, 10:29 AM
Mehdi Bouzidi
Mehdi Bouzidi - avatar
4 ответов
+ 2
For instance you can use Ajax in JavaScript to submit your JavaScript variables to PHP. If you are using jQuery, AJAX is much simpler. var value = $("#email).val (); $.ajax ({ method: "POST", url: "somephpfile.php", data: {content: value} }); using this code when a form is submitted (use submit event) you can pass a variable named content to a php file named somephpfile.php the you can acess the content variable in php using $_POST['content']
25th Jan 2017, 5:43 PM
Parker Queen
Parker Queen - avatar
+ 1
JSON is used to pass data to and from PHP and JavaScript.
25th Jan 2017, 12:21 PM
Andre van Rensburg
Andre van Rensburg - avatar
0
this is also a problem for me, cause i know how To decode a JSON but i don't know how To encode it ! i made researchs but i didn't find anything !
25th Jan 2017, 1:05 PM
Mehdi Bouzidi
Mehdi Bouzidi - avatar
0
is there another way without using Ajax ?
25th Jan 2017, 9:00 PM
Mehdi Bouzidi
Mehdi Bouzidi - avatar