File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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: 509
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: 61772
    
  67

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: 509
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: 61772
    
  67

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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: jQuery : How can I iterate over Java HashMap<Long,String> into Javascript?