I have this function to write the inputs from a form to the database and i'm trying to simplify the data being passed by the ajax call to the php. Currently i have this function:
function writeDB(stage){
var userData = $("#cacheDB").find("input").get();
var ajaxData = []
for (var n=0;n < userData.length; n++){
item = {};
item[userData[n].id] = userData[n].value;
ajaxData.push(item);
}
$.ajax({
url: "x.php",
data: {ajaxData},
});
}
Which sends out this object:
http://url.php?ajaxData[0][pageid]=1&ajaxData[1][input1]=John&ajaxData[2][input2]=Doe
I would like to send only the original data key, like:
http://url.php?[pageid]=1&[input1]=John&[input2]=Doe
Or
http://url.php?pageid=1&input1=John&input2=Doe
Is it posible? I've tried several methods and havn't found one suitable yet.