如何在获得ajax响应后完全隐藏引导模式

如何在获得ajax响应后完全隐藏引导模式,ajax,twitter-bootstrap,cakephp,response,Ajax,Twitter Bootstrap,Cakephp,Response,我使用cakephp,使用ajax呈现元素,并在ctp中动态加载数据。但是在ajax成功函数中得到ajax响应后,我试图关闭引导模式,但模式并没有完全关闭,留下了一些透明的背景 使用此选项清理左侧背景 // From Ctp hcp_btn.on('click', function(){ var value = hcp_field.val(); if(value != '') { $.ajax( {

我使用cakephp,使用ajax呈现元素,并在ctp中动态加载数据。但是在ajax成功函数中得到ajax响应后,我试图关闭引导模式,但模式并没有完全关闭,留下了一些透明的背景

使用此选项清理左侧背景

// From Ctp
hcp_btn.on('click', function(){
    var value = hcp_field.val();
        if(value != '')
        {
            $.ajax(
            {
                type: 'POST',
                url: ajax_url+'users/add_hcp_type/'+value,
                success:function(response)
                {
                    if(response == 'exist')
                    {
                        $("#hcp_error").show();
                        hcp_btn.addClass('disabled');
                    }
                    else{
                        $("#hcp_type_modal").modal('hide');
                        $("#hcp_type").html(response);
                    }
                }
            });
        }
    });

// For Controller
$this->autoRender = false;
$this->layout = 'ajax';
$this->viewPath = 'Elements';
$this->render('hcp_types');


![This type of background left after modal close in ajax success function][1]

我必须把这个代码放在哪里。。。在my元素或ctp中呈现元素,或在$hcp_type_modal.modal'hide'之后;您可以将其放在ajax开始之前,因为您建议我将代码放在ajax开始之前。。在$.ajax函数之前,但问题仍然存在..将其放在hcp_btn之前.单击,函数{不工作..问题仍然存在
//when hidden
$('#hcp_type_modal').on('hidden.bs.modal', function(e) {
 $('.modal-backdrop').remove(); 
});