I try to dynamically change the key of the object data in jQuery.
Below is my code:
// User is "finished inputing selection or typing," do something
function doneInput (e) {
var $column = 'product_title'
$.ajax({
url: draftUrl,
type: 'POST',
data: {$column : $value
},
success: function (data) {
console.log(data);
if ($eventId){
// Dbs mean draft saved box an extenstion to make it unique;
displayDraft('#'+$eventId+'Dsb');
}
},
error: function(jqXHR, errMsg) {
// Handle error
alert(errMsg);
}
});
} // End of doneinput function
I got the below result
Array
(
[$column] => Blue addidas men's jeans
)
I wanted something like:
Array
(
[product_title] => Blue addidas men's jeans
)
And I couldn't enter it manually since I will be changing the value of '$column' dynamically.