wood burning stoves 2.0*
The moose likes HTML, CSS and JavaScript and the fly likes jQuery : How can I iterate over Java HashMap<Long,String> into Javascript? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "jQuery : How can I iterate over Java HashMap<Long,String> into Javascript?" Watch "jQuery : How can I iterate over Java HashMap<Long,String> into Javascript?" New topic
Author

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

Saurabh Pillai
Ranch Hand

Joined: Sep 12, 2008
Posts: 506
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

Joined: Jan 10, 2002
Posts: 60782
    
  65

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.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Saurabh Pillai
Ranch Hand

Joined: Sep 12, 2008
Posts: 506
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

Joined: Jan 10, 2002
Posts: 60782
    
  65

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.
 
subject: jQuery : How can I iterate over Java HashMap<Long,String> into Javascript?
 
Similar Threads
using c:forEach to iterate over Map<String, ArrayList<Hashmap>>
how to show map of maps in jsp,struts
Custom JSP Tag
Ordered and Sorted
retrive Vector from HashMap