title: Codeigniter ajax country state dropdown is not working
body: <p>Hi I am having registration form which inlcudes countries and stated dropdown.Not able to get the states list after slecting countries.In Console getting response as page not found.Here is my code.</p>
  
  <p>Controller:</p>
  
  <pre><code>function signup()
  {
      $this-&gt;load-&gt;library('form_validation');
      $this-&gt;form_validation-&gt;set_error_delimiters('&lt;br /&gt;&lt;span class="error"&gt; ','&lt;/span&gt;');
  
      $this-&gt;form_validation-&gt;set_rules('country_id','Country Name','required');
      $this-&gt;form_validation-&gt;set_rules('state_id','State Name','required');
      $this-&gt;form_validation-&gt;set_rules('city_id','City Name','required');
      if($this-&gt;form_validation-&gt;run()== FALSE)   
     {    
      $data['country'] = $this-&gt;signup_model-&gt;getcountry();  
      $data['mainpage']='signup';
      $this-&gt;load-&gt;view('templates/template',$data);
      }
  else
      {
          $this -&gt; signup_model -&gt; insertprofiledetails();
          $this-&gt;flash-&gt;success('&lt;h2&gt;Profile Details Added Successfully!&lt;/h2&gt;');
          redirect('welcome/add');
      }
  }
  
  public function ajax_state_list($country_id)
  {
      $this-&gt;load-&gt;helper('url');
      $this-&gt;load-&gt;model('signup_model');
      $data['state'] = $this-&gt;signup_model-&gt;getstate($country_id);
      $this-&gt;load-&gt;view('ajax_get_state',$data);
  }
  </code></pre>
  
  <p>Model: </p>
  
  <pre><code>function getcountry()
   {
      $this -&gt; db -&gt; select('*');
      $query = $this -&gt; db -&gt; get('countries');       
      return $query-&gt;result();
   }
  
    function getstate($country_id='')
   {
      $this -&gt; db -&gt; select('states.*');
      $this -&gt; db -&gt; where('country_id', $country_id);
      $query = $this -&gt; db -&gt; get('states');
      return $query-&gt;result();
   }
  </code></pre>
  
  <p>View:</p>
  
  <pre><code>&lt;script&gt;
      function getstatedetails(id)
      {
          //alert('this id value :'+id);
          $.ajax({
              type: "POST",
              url: '&lt;?php echo base_url();?&gt;welcome/ajax_state_list '+id,
              data: id='cat_id',
              success: function(data){
                  //alert(data);
                  $('#old_state').html(data);
          },
           });
      }
  &lt;/script&gt;
  &lt;div class="form-group"&gt;
      &lt;label class="sr-only" for="form-address2"&gt;Country&lt;/label&gt;                                              
      &lt;select name="country_details" class="form-control countries" id="country_details" onChange="getstatedetails(this.value)"&gt;
            &lt;option value="" selected="selected" &gt;Select Country&lt;/option&gt;
             &lt;?php foreach($country as $count): ?&gt;
              &lt;option value="&lt;?php echo $count-&gt;country_id; ?&gt;"&gt;&lt;?php echo $count-&gt;country_name; ?&gt;&lt;/option&gt;
              &lt;?php endforeach; ?&gt; 
      &lt;/select&gt;
  &lt;/div&gt;
  &lt;div class="form-group"&gt;
      &lt;label class="sr-only" for="form-address2"&gt;State&lt;/label&gt;
      &lt;select name="select_state" class="form-control countries" id="old_state" onChange="getcitydetails(this.value)"&gt;
             &lt;option selected="selected"&gt;Select State&lt;/option&gt;
      &lt;/select&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>ajax_get_state:</p>
  
  <pre><code>&lt;select name="select" onChange="getstatedetails(this.value)"&gt;
   &lt;option value="" selected="selected" &gt;Select State&lt;/option&gt;
   &lt;?php foreach($state as $stt): ?&gt;
    &lt;option value="&lt;?php echo $stt-&gt;state_id; ?&gt;"&gt;&lt;?php echo $stt-&gt;state_name; ?&gt;&lt;/option&gt;
   &lt;?php endforeach; ?&gt; 
   &lt;/select&gt; 
  </code></pre>