I have an array of objects that I am trying to send to my PHP script. Before sending the array I can access all the data in it and everything is there. Once it gets to PHP var_dump returns NULL. I'm not quite sure how to send the 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);
});
The array:
var obj = [
{
"key": "val",
"key2": "val2"
},
{
"key": "val",
"key2": "val2"
}
]
obj.push({"key":val,"key2":val2});
chrome.storage.local.set({'object':obj});