我使用选择框从下拉电子邮件列表中选择电子邮件,如果用户选择电子邮件,我调用一个 javascript 函数来调用 ajax,此 ajax 函数返回所选电子邮件的 imap 函数返回值,一切都很好,但电子邮件下拉没有当用户选择电子邮件时关闭,只有在 ajax 响应完成后才会关闭,
这是我的 HTML 下拉列表
<div class="row">
<div class="col-md-12">
<div class="form-group m-form__group">
<select name="info_email" id="info_email" class="form-control m-bootstrap-select m_selectpicker" data-live-search="true" onchange="get_mail_content_block(this.value);">
<option value="">Choose Email</option>
<?php
$admindata = $this->session->userdata('admindata');
if ($admindata['email_id'] != '') {
$users_email_info = get_users_mail_details_if_exist($admindata['email_id']);
if(count($users_email_info) > 0){
echo "<option value=".$users_email_info->email_detail_id.">".$users_email_info->email_ID."</option>";
}
}
?>
<?php
if(!empty($email_lists))
{
foreach ($email_lists as $key => $email_list) { ?>
<option value="<?php echo $email_list->email_detail_id; ?>" <?php if($default_email == $email_list->email_detail_id){ echo 'selected'; }else{ echo ''; } ?>><?php echo $email_list->email_ID; ?></option>
<?php }
}
?>
</select>
</div>
</div>
</div>
在上面我调用了 get_mail_content_block(id); Javascript函数是
function get_mail_content_block(val)
{
$('#mailbox_loader_img').show();
$.ajax({
type: "POST",
url: baseurl+'Mailbox/email_content_block',
async: false,
type: "POST",
data:{'email_id':val },
dataType: "html",
success: function(response)
{
$('#mailbox_loader_img').hide();
$('#mail_content_append_block').empty().append(response);
}
});
}
一只萌萌小番薯