title: get value of array in ajax, ruby on rails
body: <p>I'm using ajax to check validate in client side, but i don't know how to get value in array of ruby on rails. Here is my ajax:</p>
  
  <pre><code>&lt;script&gt;
      $(document).ready(function() {
          $("#button").click(function() {
              var email = $("#email").val();
              var name = $("#username").val();
              var phonenumber = $("#phonenumber").val();
              var pass = $("#password").val();
              var names = $("divname").toString();
              console.log(names);
              ....
          });
      }); 
  &lt;/script&gt;
  </code></pre>
  
  <p>When i check Console.log, I just see "Object" but not values of array:</p>
  
  <pre><code> "[object Object]"
  </code></pre>
  
  <p>Here is my array, call by ruby on rails:</p>
  
  <pre><code>&lt;% @usernames.each do |t| %&gt;
  &lt;div id="divname"&gt;&lt;%= t.username %&gt;&lt;/div&gt;
  &lt;%end%&gt;
  </code></pre>
  
  <p>Here my coontroller:</p>
  
  <pre><code>def index
      @usernames = User.find(:all, :select =&gt; "username")
      @user = User.create(:username =&gt; params[:username], :password =&gt; params[:password],
                          :email =&gt; params[:email], :phonenumber =&gt; params[:phonenumber])
      if @user 
        render 'index'
      else
        render 'index'
      end
  </code></pre>
  
  <p>So, please! help me to fix that :)</p>