• Post Reply Bookmark Topic Watch Topic
  • New Topic

get value in database using js function  RSS feed

 
Ranch Hand
Posts: 128
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.
 
author & internet detective
Sheriff
Posts: 37839
585
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?
 
Author and ninkuma
Marshal
Posts: 66404
156
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: 66404
156
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.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!