follow this code:
Script:
<script type="text/javascript"> $('#submit').click(function() { var Arraydata = ["Jan 2017", "Feb 2017", "Mar 2017"]; str_json = JSON.stringify(Arraydata); var newForm = $('<form>', { 'action': 'script.php', 'target': '_top', 'method': 'POST' }).append($('<input>', { 'name': 'data', 'value': str_json, 'type': 'hidden' })); $(document.body).append(newForm); newForm.submit(); }); </script>
PHP:
<?php if(isset($_POST['data'])) { $_SESSION['data'] = json_decode(stripslashes($_POST['data'])); } ?>
Question and answer is powered by AnsPress.io