Wednesday 15 August 2012

Ajax to Rails through jQuery arrays -


Code> search_array = [AR1, AR2]; In the console, it tells me what this is happening:

  search_array = & gt; {"0" = & gt; ["Merchant"], "1" => ["X1"]}   

Which is correct.

How do I use the values ​​of each array? I am able to access only arrays of values ​​through the general declaration: ArrayInRails = params [: searchArray]

and then the general call such as:

  myVar = myArrayInRails [0]   

Get more value, but I can not go deeper with it:

  MyVar = myArrayInRails [0] [0]   

This gives me:

  undefined method '[]' for zero: nilClass < / Code>   

What is your hash, so that you have it Should not be accessed through intercession. The keys must be done through this, pay:

  consultation [[search_array] ['1']   

or

  consultation [: search_array] [: 1]    

No comments:

Post a Comment