• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how to iterate response object in a table

 
Abdul Wahab
Ranch Hand
Posts: 49
Eclipse IDE Java MySQL Database
  • 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..
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64620
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • 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 Java MySQL Database
  • 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
Author and ninkuma
Marshal
Pie
Posts: 64620
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is the response returning?
 
Abdul Wahab
Ranch Hand
Posts: 49
Eclipse IDE Java MySQL Database
  • 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
Author and ninkuma
Marshal
Pie
Posts: 64620
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • 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 Java MySQL Database
  • 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 Java MySQL Database
  • 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
Author and ninkuma
Marshal
Pie
Posts: 64620
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • 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 Java MySQL Database
  • 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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic