This week's book giveaway is in the OCAJP forum.
We're giving away four copies of OCA Java SE 8 Programmer I Study Guide 1Z0-808 and have Jeanne Boyarsky & Scott Selikoff on-line!
See this thread for details.
The moose likes HTML, CSS and JavaScript and the fly likes Ajax JSON looping in jQuery Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA Java SE 8 Programmer I Study Guide 1Z0-808 this week in the OCAJP forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Ajax JSON looping in jQuery" Watch "Ajax JSON looping in jQuery" New topic
Author

Ajax JSON looping in jQuery

Tarik Ansari
Ranch Hand

Joined: Dec 31, 2008
Posts: 50
Hi All,

I am new to jQuery, could you please let me know how do i loop the below JSON and display result in success of AJAX (Result appended in a div)

JSON format


Below AJAX method


Any leads on how to loop and display the JSON object would be appreciated.

Thanks
Tarik
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61985
    
  67

Tarik Ansari wrote:Any leads would be appreciated.

Any leads on what? What's the problem?

Also, please edit your post to properly indent the JavaScript code. Unformatted/unindented code is harder to read.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
There is no need to parse the JSON, it should be in JSON already.

Eric


Tarik Ansari
Ranch Hand

Joined: Dec 31, 2008
Posts: 50
Eric, JSON is already available, i need to know how to loop the result of the JSON (Say for loop JSON object and pull the value)
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61985
    
  67

Once it's been evaluated, it's no longer JSON. JSON is the serialized text format; after evaluation, it's just a JavaScript object like any other.

As it's not any array, why the need to "loop"? Are are you trying to iterate over the properties rather than directly address them?
 
jQuery in Action, 2nd edition
 
subject: Ajax JSON looping in jQuery