SQL query using ajax only and display in html page

222 views Asked by At

I'm having a table product in the database pascal, I'm using Mysql (Xampp) to store the database. I want to "Select * from product". I want to have ajax script that can query the sql statement and display it on a html page. I dont want to have any .php files. Can someone help me.. Thank you.

1

There are 1 answers

0
hbCyber On

I don't think that's possible.

AJAX queries send XmlHttpRequests -- basically, messages over the HTTP protocol. And MySQL does not respond to HTTP queries. That's why you need something in-between -- PHP code would receive the HTTP message, perform the SQL operation, and return the results.

The second problem you have is that having a database which can be accessed from JavaScript is absolutely not secure. It implies that the username and password used to access it are stored in your code (which anyone can see), and it implies that it accepts connections from any source, since your JavaScript code would run on anyone's computer who is visiting the page.