Reputation: 24061
In my php I'm getting
string(15) "[object Object]"
I'm posting from ajax an array consisting of:
ctx.imageData.push({name : file.name, value : this.result});
this.result is a base64 encoded image, taken from a js file reader.
How can I get the contents of object object in php?
Upvotes: 1
Views: 2966
Reputation: 597
try json_decode()
on the variable that you are getting in the php, and after that use var_dump
to check its value
Upvotes: 0
Reputation: 4858
ctx.imageData.push({name : file.name, value : JSON.stringify(this.result)});
And use json_decode
in php.
jQuery does not have functionality of its own for that, you have to use the browser built-in version or json2.js
from http://www.json.org
JSON.stringify()
is available in all major browsers, but to be compatible with older browsers you still need that fallback.
Upvotes: 1
Reputation: 2541
You probably try to push an object with javascript which is being cast to string. In PHP we get the result string(15) "[object Object]"
because the string is actually [object Object]
and you cannot get any information from it within PHP. You are making some mistake while passing the variable with javascript and you have to show us some more code to help you handle it.
Upvotes: 2