Can you get data from javascript to php?

You can pass data from PHP to javascript but the only way to get data from javascript to PHP is via AJAX. The reason for that is you can build a valid javascript through PHP but to get data to PHP you will need to get PHP running again, and since PHP only runs to process the output, you will need a page reload or an asynchronous query.
For More Information Please Refer:
You May Also Like to Read: