I can't seem to get the accordion menu to apply to new html code that's been appended using jquery. To make things more complicated I'm extracting data from mysql server using the ajax function and a for loop. When I do this, I can only apply the accordion menu to the first header.
$(document).ready(function(){
$.ajax({
url: 'database/api.php', data: "", dataType: 'json', success: function(rows)
{
for (var i in rows)
{
var row = rows[i];
var code = row[0];
var process = row[1];
$('#accordion').append("<h3>"+code+"</h3><div><p>Process: "+process+"</p></div>");
}
}
});
$("#accordion").accordion({collapsible: true, active: false});
});