-2

Possible Duplicate:
Can JavaScript connect with MySQL?

I have a database with names and emails. When the user fills a email input field with a email. JS checks it with the database and writes out persons name after he completed the email in the field.

joe@exampl.com Welcome John Doe!

Is it Possible to retrieve MySQL Database data using JavaScript?

Any help would be appreciated.

Community
  • 1
  • 1
SebastianOpperman
  • 6,988
  • 6
  • 30
  • 36
  • Fortunately, JavaScript doesn't have direct access to the database. Otherwise, it was was a godsend for hackers. It only has access to resources located on the client side. – kapandron May 03 '12 at 09:25

2 Answers2

5

Assuming a typical browser environment (since you specify client side code), no, and it would be insane to expose the database in a way that would grant a browser such permissions if it were possible.

Write a web service that the browser can interact with by using Forms or Ajax to make HTTP requests instead.

(Aside: If you hadn't specified client side, then node js can do it).

Community
  • 1
  • 1
Quentin
  • 914,110
  • 126
  • 1,211
  • 1,335
0

No. For doing such a thing, you need a server for that. What you could do, if the database resides on the same machine as the client, is using IndexedDB, giving you a means of accessing a local DB (which is a NoSQL-DB).

helpermethod
  • 59,493
  • 71
  • 188
  • 276