• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

how to iterate response object in a table

 
Ranch Hand
Posts: 49
Eclipse IDE MySQL Database Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi ranchers,
I am submitting a form via Jquery Ajax post method and i get a response object(list of rows from database) successfully.
i dont know how to set the response values in a table.

Any help..
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What's be easiest is to have the server, perhaps using a JSP, format the table rows to send as the response. Then the HTML fragment can simply be injected into the DOM.

If not that, then what are you getting back as the response? JSON data? if so, you'll need to create all the DOM elements yourself using jQuery's DOM creation capabilities.
 
Abdul Wahab
Ranch Hand
Posts: 49
Eclipse IDE MySQL Database Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

If not that, then what are you getting back as the response? JSON data? if so, you'll need to create all the DOM elements yourself using jQuery's DOM creation capabilities.


hmm.. not json..i am trying to convert to json..below is my code.. can you help me with that..
 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What is the response returning?
 
Abdul Wahab
Ranch Hand
Posts: 49
Eclipse IDE MySQL Database Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
An error occurred! SyntaxError: JSON.parse: unexpected character.. this is the error i am recieving..where am i wrong???
 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Bear Bibeault wrote:What is the response returning?

 
Abdul Wahab
Ranch Hand
Posts: 49
Eclipse IDE MySQL Database Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Actually bear when try without json (normal object) i am getting sucessfull result
out put

but when i try to convert to json i am getting the following error



 
Abdul Wahab
Ranch Hand
Posts: 49
Eclipse IDE MySQL Database Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
And what is the main difference between attributes in servlet (set or getAttribute) and json. both are object right??
 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Abdul Wahab wrote:Actually bear when try without json (normal object) i am getting sucessfull result
out put


That's not valid JSON. So of course, it cannot be converted. You'll need to fix the server code to return valid JSON. There are many Java JSON libraries to choose from.
 
Abdul Wahab
Ranch Hand
Posts: 49
Eclipse IDE MySQL Database Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

That's not valid JSON. So of course, it cannot be converted. You'll need to fix the server code to return valid JSON


yes! you are right
 
reply
    Bookmark Topic Watch Topic
  • New Topic