How to display ajax response to HTML in code igniter
<p>I need to display the json data that i receive from  ajax request to html </p>

<p>In alert i am getting the json data</p>

<p>Here is my view </p>

<pre><code> &lt;?php for ($i=0; $i&lt;5; $i++){?&gt;
&lt;a href="#" class='testing' data-index="&lt;?= $i;?&gt;" &gt;testlink&lt;/a&gt;

   //need to display the results that i fetch from ajax request

  &lt;?php }? &gt;
   }
</code></pre>

<p>Here is my jquery </p>

<pre><code>$('.testing').click(function() {

$.ajax({
    url : "path_to_your_controller",
    data: {
        id: $(this).data("index")
    },
    type: "POST"
    success: function(data)
    {
        alert(data);
    },

});
</code></pre>

<p>Here is my controller </p>

<pre><code>   $data= array('value' =&gt;22,
                    'value2'       =&gt; 32,
                    'value3'       =&gt; 'foo',
                    'value4'       =&gt;  'bar',
                    'value5'       =&gt; '122',
            );
     echo json_encode($data);
</code></pre>