I got data from third party plugin and I just got [object Object]
in javascript. I want to pass it on PHP
and show all the values on that [object Object]
. How could I to do that ? I already pass it to PHP
through GET
I got this [object Object]
from this part.
widget.createButton()
.attr('title', "Save chart")
.on('click', function (e) {
widget.save(function(data) {
window.location.href = "temp.php?var=" + data;
})
})
.append($('<span>save chart</span>'));
This is my PHP
code.
<?php
$var = $_GET['var'];
var_dump($var);
exit();
?>
if I do var_dump
it still get [object Object]
but I want to get the values of that [object Object]
.
Your object is being converted to a string. Try this in a browser console to see.
var a = {}
a.toString() // this will give you [object Object]
In your code at this step:
window.location.href = "temp.php?var=" + data;
you are converting data from object
to string
. You need to do this
window.location.href = "temp.php?var=" + JSON.stringify(data);
and on PHP part of the code, you will now receive it as string, so you need to do this:
$var = var_dump(json_decode($_GET['var']));