$('li.clickable').on('click', function() {
var list = $(this);
$.ajax({
url: 'url_to_script',
method: 'post',
success: function(res) {
var response = $(res); // assume that you response contains li tags i.e '<li>subitem 1</li>' and more
list.append(response); // append response to list that clicked
/* >> OR << */
// if you response contains data as array/field
$.each(res, function(index, data) {
list.append('<li>'+ data['some_text'] +'</li>'); // some_text is assumed property, you have something else
});
// ACCORDING TO YOUR COMMENT
var sublist = '<ul>';
$.each(res, function(index, data) {
sublist += '<li>'+ data['some_text'] +'</li>'; // some_text is assumed property, you have something else
});
sublist += '</ul>'; // now sublist is like <ul><li>...</li>....</ul>
list.append(sublist); // append the sublist to ul.clickable
}
});
});
注意:您必须制作一些 CSS 来改善外观