AJAX变量为html

If I have this code in AJAX success..

success: function(msg) {
    var msg = $.parseJSON(msg);
        new_name = msg.Name;
        var html_new_name = new_name;
        $('#new_project_name').append(html_new_name);
        $('#myModalAlertSuccess').modal('show');
    }

How can I access the variable html_new_name in AJAX to HTML..Like this:

<a href='<?php echo base_url('generator/view_generate'.$html_new_name) ?>'>
  <button type="button" class="btn btn-primary" id="view" data-dismiss="modal">
    View
  </button>
</a>

So that I can use the variable html_new_name to another method in Controller.

Or if it is not possible? Is there any other way?

AJAX success..

success: function(msg) {
    var msg = $.parseJSON(msg);
        var link = $("#myLinke").attr('href');
        $("#myLinke").attr('href', link + msg.Name)                

    }

html :

<a id="myLinke" href='<?php echo base_url('generator/view_generate') ?>'>
  <button type="button" class="btn btn-primary" id="view" data-dismiss="modal">
    View
  </button>
</a>
success: function(msg) {
    var msg = $.parseJSON(msg);
        new_name = msg.Name;
        var html_new_name = new_name;
        $.ajax({
               type: 'POST',
               data:{'htmlname' : html_new_name},                
               url: '/path/to/your/anothercontroller/post_action',
               success:function(data){
                   alert('it worked');
               }
           });
        $('#new_project_name').append(html_new_name);
        $('#myModalAlertSuccess').modal('show');
    }

anothercontroller.php

public function post_action()
{   
    if($this->input->post('htmlname') == "")
    {
        $htmldata = "";
    }
    else
    {
        $htmldata = $this->input->post('htmlname');
    }
    echo $this->load->view('template/content', $htmldata,  TRUE);
}

Now you can access $htmldata in your corresponding view