What you are trying to initialize is an object, not an array. You can initialize objects in two ways:
var postdata = {};
Or:
var postdata = new Object();
Then you can assign keys and values ββin the same way as you:
postdata['name'] = "data";
Or:
postdata.name = "data";
You can also create your object at the initialization stage:
postdata = {
name: "data"
}
source
share