title: Get a single row from the database using AJAX in CodeIgniter?
body: <p>I wonder how to get data from database using AJAX in CodeIgniter. Could you please check the code below to find out the reason of problem? Nothing happens when I click on the link from my view.</p>
  
  <p>Here is my view:</p>
  
  <pre><code>&lt;a href="#" class="faq_title"&gt;&lt;?php echo $faq_title; ?&gt;&lt;/a&gt;
  </code></pre>
  
  <p>Here is my controller:</p>
  
  <pre><code>public function get_faq_data() {
      $this-&gt;load-&gt;model("model_faq");
      $title = $_POST['title'];
      $data["results"] = $this-&gt;model_faq-&gt;did_get_faq_data($title);
      echo json_encode($data["results"]);
  }
  </code></pre>
  
  <p>Here is my model:</p>
  
  <pre><code>public function did_get_faq_data($title) {
      $this-&gt;db-&gt;select('*');
      $this-&gt;db-&gt;from('faq');   
      $this-&gt;db-&gt;where('faq_title', $title); 
  
      $query = $this-&gt;db-&gt;get('faq');
  
      if ($query-&gt;num_rows() &gt; 0) {
          return $query-&gt;result();
      } else {
          return false;
      }
  }    
  </code></pre>
  
  <p>Here is my JavaScript file:</p>
  
  <pre><code>$(".faq_title").click(function() {
      var title = $(this).text();
  
      $.ajax({
          url: 'faq/get_faq_data',
          data: ({ title: title }),
          dataType: 'json', 
          type: 'post',
          success: function(data) {
              response = jQuery.parseJSON(data);
              console.log(response);
          }             
      });
  });
  </code></pre>