If i have my form elements with values in variable data (contains: var data = $(this).serializeArray();)
How can i do change the value of an form element (called recipient), when it's inside data?
So my element with name=recipient have value "mama", how can I change it to "papa" on ajax success
You can iterate through your objects in the array, change the object's value:
for (var item in data)
{
if (data[item].name == 'recipient') {
data[item].value = 'papa';
}
}
$.each(data, function(key, data)
{
if (this.name == "recipient")
this.value="papa";
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With