Win a copy of Java Challengers this week in the Java in General forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • paul wheaton
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Liutauras Vilda
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Piet Souris
Bartenders:
  • salvin francis
  • Mikalai Zaikin
  • Himai Minh

Need Help in accessing the JSON object in Jquery ajax call.

 
Greenhorn
Posts: 25
Hibernate Eclipse IDE
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all ,

i am using spring ,Jquery .The problem is i am using jquery ajax call to call one controller method and trying to access the values form the response object in the success function but i can see the response in fire bug but not able ti access the response object

Here is my ajax code

Here is my controller code

Here APIConstants.RESPONSE_ATTR) is constant with value "response".

Now i the response i am seeing in the fire bug looks like this

{"response":["100003683213379","100003683213379","100003987135664","100003987135664","100003987135664"]}

Now i want to get the values from the above response .Please help me in this .

 
Bartender
Posts: 1682
7
Android Mac OS X IntelliJ IDE Spring Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This really is not a spring question at all but a jquery question. Posting this in the correct forum in the future will probably get you better responses.

Will this get you started?



outputs


see here:
http://jsfiddle.net/XsMK2/30/
 
silamala ramesh babu
Greenhorn
Posts: 25
Hibernate Eclipse IDE
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Bill,

Thanks for your reply.

Here you hard coded the value in the parseJSON method but we don't know how ow many values will come in the response.
And that to i want to get the value from the key.

Any how i put your code in the success function of ajax call. I am seeing the error in fire bug like ReferenceError: RESPONSE_STATUS_ERROR is not defined
If i click on the error it is going to line

And can you suggest me any online tutorial to start with jquery and json in spring mvc
 
Bill Gorder
Bartender
Posts: 1682
7
Android Mac OS X IntelliJ IDE Spring Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Right well that was hard coded for illustration purposes only. In your example you had a response object, it would be the same result, the number of elements in the JSON array is really not relevant. Because you returned a simple string array as json it looks a little different than the key value pair json that is typically seen. If click that jfiddle link and play around I think you will find its the value that you want.

*Note the .each() I am iterating over the values
 
I’m tired of walking, and will rest for a minute and grow some wheels. This is the promise of this tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
reply
    Bookmark Topic Watch Topic
  • New Topic