Here's the code.
var postData={};
event.stopPropagation();
postData.action='preview';
postData.data=$("form#gaarrl").serializeArray();
var n=[];
n['name']='media';
n['value']=imgName;
postData.data.push(n);
console.dir(postData);
$.post("database.php",{postData },
The console.dir command shows the media:imgName as a part of the postData.data as expected but the database.php $_REQUEST only shows the elements from the serializeArray step.
What is happening?
Thanks, Jim.
Try changing var n = [];
to var n = {};
.
This fixed it for me.
This is because normal Javascript arrays do not allow keys, just numerical indexes. {}
is shorthand for new Object()
, and allows you to give it multiple named attributes.