Hello i want to acess data from my mysql server in javascript. But i have no clue how to do so. I am running tomcat so it is not handy to use php. Can someone please help me !
I thought maybe there is some way to get the variables from my servlet, but it seems not possible to get javascript connected to java or is there ?
var blueDates = magic way to get data from my mysql server;
Greetings, Rick
-
3JavaScript is (mostly) a client-side language. You'll need to communicate to the server that's hosting your database, and use some sort of server-side language to actually query the database.Cerbrus– Cerbrus2015年02月09日 10:11:21 +00:00Commented Feb 9, 2015 at 10:11
-
"but it seems not possible to get javascript connected to java" What do you mean exactly by that? Perhaps you are running into CORS restrictions? en.wikipedia.org/wiki/Cross-origin_resource_sharingGimby– Gimby2015年02月09日 12:49:17 +00:00Commented Feb 9, 2015 at 12:49
1 Answer 1
You have to implement a servlet that returns the data from mysql. A good way to do so is to implemente a servlet that returns a JSON object containing the mysql data.
Once this is done use AJAX to ask the servlet for the data.
There is a lot of information about implementing this. After all this is a minimal REST implementation for a GET request. Just ask Stackoverflow or Google.