i have a menu. These menu includes some artists and when admin clicks checkboxes, the artists is inserted to DB.
first of all,
function AddDataImdb(par, par2, par3) {
var artistIds = [];
$("input[name='" + par + "']:checked").each(function () {
artistIds.push($(this).val());
});
$.post('/json/management/AddDataImdbAjax', {
"artistIds": artistIds
}, function (response) {
if (response == 'error') {
alert("Sanatçı bulunamadı, yönlendiriliyorsunuz");
window.location.replace("myurl");
} else {
alert("succesfully added");
$("#" + par2 + "").append(('<br /><input type="checkbox" name =' + par + ' value=' + response + ' />' + par3 + '<br />'));
}
});
}
With above code, i can add my div the new added artists.
The problem is that when admin insert 2 or more artist, it shows the last one as added
$("#"+par2+"").append(('<br /><input type="checkbox" name ='+par+' value='+response+' />'+par3+'<br />'));
Above code add the div. How can i add these as array ? What can i do ?
response? it is not showing the last div, I think it appends only one div. To add multiple div you should loop over yourresponseresponseformatted?