I'm facing an issue where I have an array of objects that need to be sent to a PHP script. Initially, all the data is accessible within the array, but once it reaches the PHP script, a var_dump call returns NULL. I'm struggling to figure out how to properly send this data.
chrome.storage.local.get('object', function (object) {
var xmlhttp = new XMLHttpRequest();
xmlhttp.onreadystatechange = function () {
if (xmlhttp.readyState==4 && xmlhttp.status==200) {
alert(xmlhttp.responseText);
}
}
xmlhttp.open("POST", "http://example.com/php.php", true);
xmlhttp.setRequestHeader("Content-type","application/x-www-form-urlencoded");
var uid = 2;
JSON.stringify(object);
xmlhttp.send("json=" + object + "&uid=" + uid);
});
This is the array in question:
var obj = [
{
"key": "val",
"key2": "val2"
},
{
"key": "val",
"key2": "val2"
}
]
obj.push({"key":"val","key2":"val2"});
chrome.storage.local.set({'object':obj});