Tag Archives: POST

read POST variables with Javascript using PHP

Written by Garry Lachman (Admin). Filed under JavaScript, PHP + mySQL. Tagged , , , , , , . .

Hi,
Today i will show very easy way to read POST variables from Javascript using PHP.

1
2
3
<script type="text/javascript">// <![CDATA[
var post_json = "<?php echo json_encode($_POST); ?>";
// ]]></script>

We encode all POST vars with php to javascript JSON.
Now we can access the vars in simple way:

1
post_json.var_name;

Have a nice day,
Garry

Share