Reputation: 1401
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 ?
Upvotes: 0
Views: 332
Reputation: 41
can you state more? what is the content of the response?
if your response is a list then you may do this:
$.each(reponse, function () {
//append as div
}):
Upvotes: 1