Codeigniter Ajax工具提示

I want to make pop up tooltips with dynamic data from db when cursor hover to link, but I'm doing something wrong. Correct my code please.

My view

    <script type="text/javascript">
        $(document).ready(function() {
            $('.tip').tooltip();
        });
    </script>
    <script type="text/javascript" language="javascript">
        jQuery(document).ready(function(){
       $('#something').mouseover(function(){
        $.ajax({
         url: "<?=base_url();?>aircraft/tip",
         type: 'POST',
         data: {
          'id': $(this).attr("rel"),
         },
         dataType: 'json',
         success: function(aircraft_j) {
                  $('#something').attr('data-original-title',aircraft_j);  
              }
        });
        return false;
       });
      });
      </script>

    <a href="#" data-toggle="tooltip" data-placement="right" id="something" title="" 
data-original-title="" rel="1" class="tip">aircraft</a>

My controller

 function tip() {
    $this->output->enable_profiler(false);
    if($this->input->server('HTTP_X_REQUESTED_WITH') != 'XMLHttpRequest'){ echo "fail. try something else"; return; }
    $this->load->model('aircraft_model');
    $idd = $this->input->post('id');
    $aircraft_j = array();
    $aircraft_j = $this->aircraft_model->get_aircraft_tip($idd);
    echo json_encode($aircraft_j);
    }

My model

 function get_aircraft_tip($idd) {
    $this->db->where('id',$idd);
    $query = $this->db->get('aircraft');
    return $query->row_array();
    }

Ok, as you said that you are using bootstrap tooltip. here's how you should do it:

in your html:

<a href="#" data-toggle="tooltip" id="something" title="" 
data-original-title="tooltip data goes here">whatever you want</a>

and as I can see you have no problems with your ajax and CI controller but you have to make a slight change to your success function like this:

success: function(aircraft_j) {
                  $('#something').attr('data-original-title',aircraft_j);  
              }

Also: you can read about prop() which might be helpful to you.

Problems you might face..

In your CI tip function I see echo json_encode($aircraft_j); so your $aircarft_j variable should be a 'string' data type. As I can see you are returning $query->row_array(); from your model, so you might need to work with it as an array . here you can find a good explanation about that.