I am making an AJAX request and I need to send a complete PHP object. This is my JS code:
new Ajax.Request("some url",
{
method: 'post',
parameters: {
string1:"whatever",
myobject: this is where I want to send a PHP object named $product
}
...
});
Whats the best way? Maybe using serialization?
Thanks for your help :)!
json_encode($object)should work fine (not 100% sure what happens toprivateandprotectedmembers though, I guess they wouldn't be included)unserialize()on it. Use a regular JSON object, and populate your PHP product object from the JSON within the PHP program.