Currently, I have a function in place that writes form inputs to the database and I am looking to streamline the data passed through the ajax call to PHP. Here is the existing 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},
});
}
This function currently generates this object:
http://url.php?ajaxData[0][pageid]=1&ajaxData[1][input1]=John&ajaxData[2][input2]=Doe
I am aiming to send only the original data key like so:
http://url.php?[pageid]=1&[input1]=John&[input2]=Doe
Or
http://url.php?pageid=1&input1=John&input2=Doe
Is there a way to achieve this streamlined format? I have experimented with various methods but haven't found a suitable solution yet.