Can't get data from a codeigniter function with ajax <p>This is what I've got so far:</p> <p>This function that returns data from the model:</p> <pre><code>function get_user2() { $this-&gt;load-&gt;model('my_model'); $id=$this-&gt;input-&gt;post('users1'); $users2=$this-&gt;my_model-&gt;get_relations($id); return $users2; } </code></pre> <p>the model function:</p> <pre><code>function get_relations($usr) { $this-&gt;db-&gt;where('id',$usr); $rel=$this-&gt;db-&gt;get('relacion'); if($rel-&gt;num_rows!=0) { $relacion=array(); foreach ($rel-&gt;result_array() as $row) { $relacion[]=array( 'id'=&gt;$row['id'], 'username1'=&gt;$row['username1'], 'username2'=&gt;$row['username2'], ); } return $relacion; }else{ return false; } } </code></pre> <p>and in my view:</p> <pre><code>&lt;select name="users1" id="drop1"&gt; &lt;?php if($opciones!=false){ foreach ($opciones as $row) { echo '&lt;option value="'.$row['user_id'].'"&gt;'.$row['username'].'&lt;/option&gt;'; } } ?&gt; &lt;/select&gt; &lt;script src="jquery.js"&gt;&lt;/script&gt; &lt;script type="text/javascript"&gt; $("#drop1").change(function(){ $.ajax({ type: "POST", url: "example.com/CI/index.php/evaluation/get_user2", data: "users1="+$('#drop1').val(), success: function(){ alert('it works!'); } }); }); &lt;/script&gt; </code></pre> <p>I want to fill a second dropdown with the options returned by the controller function, but the ajax request doesn't do anything so I haven't even got to that part. Can someone help me spot what's wrong? I already tested the controller and model's function and they work. And could you tell me how to fill the second dropdown's options? Thank you very much!</p>