Win a copy of Emmy in the Key of Code this week in the General Computing 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Junilu Lacar
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Ron McLeod
  • Carey Brown
Bartenders:
  • Paweł Baczyński
  • Piet Souris
  • Vijitha Kumara

how to iterate response object in a table

 
Ranch Hand
Posts: 49
Eclipse IDE MySQL Database Java
  • Mark post as helpful
  • send pies
  • 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..
 
Marshal
Posts: 67295
170
Mac Mac OS X IntelliJ IDE jQuery Java
  • Mark post as helpful
  • send pies
  • 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
  • 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
Marshal
Posts: 67295
170
Mac Mac OS X IntelliJ IDE jQuery Java
  • Mark post as helpful
  • send pies
  • 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
  • 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
Marshal
Posts: 67295
170
Mac Mac OS X IntelliJ IDE jQuery Java
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • 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
Marshal
Posts: 67295
170
Mac Mac OS X IntelliJ IDE jQuery Java
  • Mark post as helpful
  • send pies
  • 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
  • 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
 
The only taste of success some people get is to take a bite out of you. Or this tiny ad:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!