0

i have an array of object that i created and populated by JavaScript now i want to send it another page where work is performed on that array but in php so any way to get data of javascript array in php like $phparray = $_Post['javascriptArray'];

Tushar Gupta - curioustushar
  • 58,085
  • 24
  • 103
  • 107
user3262732
  • 240
  • 1
  • 4
  • 15

2 Answers2

0

You can use ajax to send to php file, for example:

  var array = ['1', '2', '3', 'four', 'five'];
  $.ajax({
    url: "/file.php",
    method: 'POST',
    data: {
      dataToSend:array
    }
  });    

and you will receive the array object in php

 <? print_r($_POST['dataToSend']?>
Netzach
  • 321
  • 2
  • 13
-1

Use javascript cookies or localstorage

Try this tut: http://www.mosync.com/files/imports/doxygen/latest/html5/localstorage.md.html

Localstorage is only works on > ie8 & all advance browsers

So u have to use localstorage with Persistance js http://pablotron.org/?cid=1557

Jain
  • 1,209
  • 10
  • 16