title: onchage dropdown data not getting refreshed in codeigniter
body: <p>I have following code to load data in website based on location selected, on change the ajax is getting fired and getting value in controller and from controller to model and going into where clause for sql by the result of sql is not getting showed on website.But always enters into else loop of <strong>model</strong></p>
  
  <p>View:</p>
  
  <pre><code>$(document).on('change','#delvloc',function(e){
        e.preventDefault();  // stops the jump when an anchor clicked.
        var title = this.value; // anchors do have text not values.
  
        $.ajax({
          url: 'index.php?route=product/category/newfunc',
          data: {'title': title}, // change this to send js object
          type: "get",
          success: function(data){
             //document.write(data); just do not use document.write
             console.log(data);
          }
        });
     });
  </code></pre>
  
  <p>Controller:</p>
  
  <pre><code>public function newfunc(){               
             $data = array(
                      'title' =&gt; $this-&gt;request-&gt;get['title']                 
                          );  
                      $this-&gt;load-&gt;model('catalog/product');      
                $this-&gt;model_catalog_product-&gt;getProducts($data);         
  
  
      }
  </code></pre>
  
  <p>Model:</p>
  
  <pre><code>    public function getProducts($data = array()) {
      $sql="SELECT p.product_id,p.city, (SELECT AVG(rating) AS total FROM monster_review r1 WHERE r1.product_id = p.product_id AND r1.status = '1' GROUP BY r1.product_id) AS rating, (SELECT price FROM monster_product_discount pd2 WHERE pd2.product_id = p.product_id AND pd2.customer_group_id = '1' AND pd2.quantity = '1' AND ((pd2.date_start = '0000-00-00' OR pd2.date_start &lt; NOW()) AND (pd2.date_end = '0000-00-00' OR pd2.date_end &gt; NOW())) ORDER BY pd2.priority ASC, pd2.price ASC LIMIT 1) AS discount, (SELECT price FROM monster_product_special ps WHERE ps.product_id = p.product_id AND ps.customer_group_id = '1' AND ((ps.date_start = '0000-00-00' OR ps.date_start &lt; NOW()) AND (ps.date_end = '0000-00-00' OR ps.date_end &gt; NOW())) ORDER BY ps.priority ASC, ps.price ASC LIMIT 1) AS special FROM monster_product p LEFT JOIN monster_product_description pd ON (p.product_id = pd.product_id) LEFT JOIN monster_product_to_store p2s ON (p.product_id = p2s.product_id) WHERE pd.language_id = '1' AND p.status = '1' AND p.date_available &lt;= NOW() AND p2s.store_id = '0'"
      if (!empty($data['title'])) {
                  $sql .= " and p.city='". $data['title'].  "' GROUP BY p.product_id";            
              }
      else{$sql .= " and p.city='Pune' GROUP BY p.product_id";}
  
  }
  </code></pre>
  
  <p>My HTML:
  <li>
                      Delivery Location:              </p>
  
  <pre><code>            &lt;select name="delvloc" id="delvloc" style="width: 100px;" "&gt;
                          &lt;?php foreach ($city as $user_group) { ?&gt;
                          &lt;?php if ($user_group['city'] == $user_group_id) { ?&gt;
                          &lt;option value="&lt;?php echo $user_group['user_group_id']; ?&gt;" selected="selected"&gt;&lt;?php echo $user_group['city']; ?&gt;&lt;/option&gt;
                          &lt;?php } else { ?&gt;
                          &lt;option value="&lt;?php echo $user_group['city']; ?&gt;"&gt;&lt;?php echo $user_group['city']; ?&gt;&lt;/option&gt;
                          &lt;?php } ?&gt;
                          &lt;?php } ?&gt;
                  &lt;/select&gt;
                  &lt;/li&gt;   
  </code></pre>