Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Database access using Java Script

 
Nee Kat
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is the best way to access/query data using javascript. I have to query an Oracle database.
Any sample code will be appreciated.

Regards,
Neekat
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
JavaScript can not access a database directly. IE can use ActiveX, but that is as close as you can get.

Eric
 
Nee Kat
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What about an XML document. Can I access data from an XML document using JS. The data is not that much so I can use an XML document. If yes, how to access using JS.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65225
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Using XMLHttpRequest (aka Ajax) you can access an XML document on the server. You cannot access anything on the client.
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The XML document also has to be on the same domain with Ajax.

Eric
 
Nee Kat
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am confused.
If the document is stored on C:\home\code\menu.xml so can I access it using this code or not from a template which is stored on the same drive?

var xmldoc = new ActiveXObject("Microsoft.XMLDOM");
xmldoc.async = false;
xmldoc.load("C:\home\code\menu.xml")



Regards,
Neekat
 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When you mentioned JavaScript, the assumption was that the document would be served by a web server, in which case you can not access a document on a local machine using the "C:\..." notation. If you open the HTML file directly on your local machine, you can, but then there's not much point in making it a web page.
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here is a basic example:



Eric
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic