Not close Dialog box

Hi all, i write a module with a frame inside a dialog, but not more close dialog.
This is my code :

Yii::app()->clientScript->registerScript('salva_dati', '    
    function send(){
    //console.log($(\'#orario-form\', window.top.frames[0].document).serialize());
          $.ajax({
            url: \'' . Yii::app()->createUrl('orario/update') . '\',
            type: \'POST\',
            dataType: \'JSON\',
            data: $(\'#orario-form\', window.top.frames[0].document).serialize(),
            success: function(data) {     // 1                 
                        if(data.retCod == 0) {  // 2
                            alert(\'Errore scrittura - Contattare assistenza\');  
                            $("#parmdialog").dialog("close");                           
                        } else { // 2
                            if(data.retCod == 1 && data.retForm.replaceAll(\' \',\'\') == \'\') { // 3 
                                 //alert($(\'document\').data(\'obj\'));
                                //$.fn.yiiGridView.update(\'orario-grid\');   
                                //$.fn.yiiGridView.update(\'fascia-grid\', {data: {\'Fascia[orario_id]\':\'0\'}});
                                //if($(\'ul#yw3 li\').length > 1)
                                //    $(\'#yw3 li:last-child\').remove();  
                             
                                $(\'#parmdialog\').dialog("close");    <------ NOT WORK
                            }else{  // 3  non validato ----                              
                                $(\'#parm-frame\').contents().find(\'body\').html(data.retForm);  
                            } // 3
                        } // 2                        
                     } // 1
        });
    
    }
', CClientScript::POS_HEAD);

How close this dialog after use

$(\'#parm-frame\').contents().find(\'body\').html(data.retForm); ?
Why not work?
Dialog object lose your refer?
Thx all
Roberto