I want to run MySQL query's on command without reloading the page. I think JavaScript can do this but i am unsure how. What i want to do is have a form with an return id field and when you fill out the form once with the return id and come back later and use that return id and it fills in in a lot of the content for them to save time.
Javascript cannot run MySQL Queries itself; however, you can use ajax to make a call to the server to retrieve the data. I like to use jQuery's ajax() for my ajax needs.
Here is an example of how jquery's ajax() method works:
$.ajax({
url: "pathToServerFile",
type: "POST",
data: yourParams,
dataType: "json"
});
You can't query with pure javascript. It has to be done from a hook that is setup on a backend.
This tends to be done with ajax.
Moreover, if querying were available from client side, then everyone could see your connection string.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With