答案 0 :(得分:1)
在success
回调中,执行以下操作:
...
success: function (data) {
if (data == "1") {
$('#kingdom_nameerr').html('Saved successfully');
// add a new option to #kg_id
$('<option></option>')
.val(name)
.text(name)
.appendTo('#kg_id');
// select the new option
$('#kg_id').val(name);
} else {
$('#kingdom_nameerr').html('Data already exists');
}
}
...
答案 1 :(得分:1)
这就是你附加选择标签
的选项//...
$('#kingdom_nameerr').html('Saved successfully');
$('#yourSelectIDonPage').append('<option value="'+someOptionID+'">'+optionSelected+'</option>');
//...