This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
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


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
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: 60740
    
  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: 60740
    
  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.
 
 
subject: jQuery : How can I iterate over Java HashMap<Long,String> into Javascript?
 
Similar Threads
Custom JSP Tag
Ordered and Sorted
retrive Vector from HashMap
using c:forEach to iterate over Map<String, ArrayList<Hashmap>>
how to show map of maps in jsp,struts