jquery - PHP read array object from javascript data object -


i create data object in jquery , pass php post method

var pd = { currentpage : 1, rowcount : 10, search : 5 };  post method --> data = pd 

in php page if superglobal $_post have this

var_dump($_post) --> array ( [data] => [object object] ) 

in php how can read $ _post ['data'] values ?

edit (full code)

var pd = { currentpage : 1, rowcount : 10, search : 5 };         pd = json.stringify(pd);  redirectpost('index.php', { data : pd });  var redirectpost = function(location, args) {     var form = '';     $.each(args, function(key, value) {         form += '<input type="hidden" name="'+key+'" value="'+value+'">';     });     $('<form action="'+location+'" method="post">'+form+'</form>').appendto('body').submit(); }; 

php

$data = json_decode($_post['data']); var_dump($data); <-- null 

it looks you're looking json_decode()-function. however, not create php-object, turn array this: $data['currentpage']. see if more luck this:

$data = json_decode($_post['data']); var_dump($data); 

Comments

Popular posts from this blog

javascript - gulp-nodemon - nodejs restart after file change - Error: listen EADDRINUSE events.js:85 -

Fatal Python error: Py_Initialize: unable to load the file system codec. ImportError: No module named 'encodings' -

javascript - oscilloscope of speaker input stops rendering after a few seconds -