How can we have JavaScript variable value in PHP variable within the same page??
I have a JavaScript variable which have the JSON String and I want to store in PHP variable so that I can store it into database. Is it possible??
How can we have JavaScript variable value in PHP variable within the same page??
I have a JavaScript variable which have the JSON String and I want to store in PHP variable so that I can store it into database. Is it possible??
You should write a php
page accepting the JSON
using post
and save it to database.
In javascript when you are ready to save the JSON
, send the JSON
to the PHP
page using AJAX
. This is the way to save some client side data without using forms.
As explained in this answer
Send JSON data from Javascript to PHP?
or if its a form you can refer this answer to submit the serialised data with HTML form