title: Ajax response inside a div
body: <p>I am trying to show the value of ajax response inside a div and for that I have the following code in my view file.</p>
  
  <pre><code>&lt;script type="text/javascript" src="MY LINK TO JQUERY"&gt;&lt;/script&gt;
  
  &lt;script  type="text/javascript"&gt;
       $(function(){ // added
       $('a.vote').click(function(){
           var a_href = $(this).attr('href');
  
       $.ajax({
              type: "POST",
              url: "&lt;?php echo base_url(); ?&gt;contents/hello",
              data: "id="+a_href,
              success: function(server_response){
                               if(server_response == 'success'){
                                    $("#result").html(server_response); 
                               } 
                               else{
                                    alert('Not OKay');
                                   }
  
                        }
    });   //$.ajax ends here
  
    return false
      });//.click function ends here
    }); // function ends here
   &lt;/script&gt;
  
    &lt;a href="1" title="vote" class="vote" &gt;Up Vote&lt;/a&gt;
    &lt;br&gt;
    &lt;div class="result"&gt;&lt;/div&gt;                                        
  </code></pre>
  
  <p>my Controller (to which the ajax is sending the value):</p>
  
  <pre><code>function hello() {
                $id=$this-&gt;input-&gt;post('id');
                echo $id;
               }      
  </code></pre>
  
  <p>Now what I am trying achieve is get the server_response value (the value that is being sent from the controller) in side <code>&lt;div class="result"&gt;&lt;/div&gt;</code> in my view file.</p>
  
  <p>I have tried the following code but its not showing the value inside the div.</p>
  
  <p>Could you please tell me where the problem is?</p>