$(document).on('focus', '.resource_person', function() {
var topic_code = $(this).attr('id');
var rp_reference = $(this).attr('selected-rp');
var option = '';
$.ajax({
type: 'POST',
url: siteUrl + 'course_management/Training_courses/topic_rp',
data: {topic_code: topic_code},
dataType: 'json',
success: function(source) {
$('.resource_person[id="'+topic_code+'"]').empty();
for (var key in source) {
if (source[key] != rp_reference) {
option += '<option value="'+source[key]+'">'+key+'</option>';
} else {
option += '<option value="'+source[key]+'" selected="">'+key+'</option>';
}
}
console.log(option);
$('.resource_person[id="'+topic_code+'"]').append(option);
}
});
});
This what was happening when I first click the dropdownWarum wird die Drop-Down-ein-Optionen von einem auf den ersten Klick angezeigt wird, wenn()
After clicking it for the second time it goes back to the normal behavior of dropdown
"Hinweis: Cache auf false einzustellen funktioniert nur mit HEAD- und GET-Anfragen." wie gesagt auf http://api.jquery.com/jquery.ajax/ –
Aber Sie gaben mir eine Idee, danke. Ich habe mein Problem gelöst, indem ich ein Laden bei Klick hinzugefügt habe, damit das Dropdown nicht vor dem Anhängen den Inhalt anzeigt. –
@LemuelDoronio danke für das Hinweis 'Hinweis' –