Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

get value in database using js function  RSS feed

 
chamini prashakthi
Ranch Hand
Posts: 125
3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a database table and I want to retrieve data.I created a java script function to show that data using an alert.
but it seems as [object] for all the dta.
this is how I use the alert.
 
Jeanne Boyarsky
author & internet detective
Sheriff
Posts: 37234
519
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What does the code look like that writes to the "data" object? Is it AJAX? What is set in the data field?
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66204
151
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The toString() method on an object will just yield "[object]". If you want to just print out all the properties for debug purposes, you can flatten the object to JSON with JSON.stringify(). Otherwise, you need to address the properties individually.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66204
151
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
P.S. alert() is a poor way to debug. Learn how to use the console (e.g. console.log()) for more robust debugging tools.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!