Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

jQuery : How can I iterate over Java HashMap<Long,String> into Javascript?  RSS feed

 
Saurabh Pillai
Ranch Hand
Posts: 527
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am returning HashMap<Long,String> from server on one of the Ajax calls. How can I iterate over the it to extract key,value pair?

Thank you
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65826
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How is it being returned? As JSON? Something else? A response must be text so you cannot be returning the actual list.

Using $.getJSON()? Something else?

We need more details.
 
Saurabh Pillai
Ranch Hand
Posts: 527
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Bear.

It is being returned as an associative array and I was able to access through a simple for loop.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65826
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Now there's a blast from the past. The term "associative array" is pretty antiquated -- and rightfully so, it isn't very accurate as what it describes isn't any sort of array. The better term to use is object hash.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!