At my Ajax response there is two variable: js, html.
The js variable contents Javascript in tag script: //Some code And html contents HTML template. How I can execute js code for html template from the successful response Ajax?
I tried this solution:
$('head').append(response.js); // not works
The full Ajax request:
getFormShare: function(type){
        var posting = $.post('/share/getFormShare', { type : type } );
        posting.done(function( response ) {
            response = $.parseJSON(response);
            $("head").append(response.js);
            $('.ShareBlock #block').html(response.html).show();
            initFileUpload(config);
            initEditor();
        });
    }
The PHP side:
$js = $this->listdata->WrapperJavaScript($specialization, array('name_field' => 'type[]', 'tab' =>'tab', 'div_element' => '.specMain', 'label' => 'Category', 'autosearch' => 'true'));
$html = $this->load->view('social/forms/video', $this->data, true);
echo json_encode(array('html' => $html, 'js' => $js)); die();
 
     
     
    