A
A
Adam2014-11-04 14:04:14
MySQL
Adam, 2014-11-04 14:04:14

Interaction of Java Script and SQL?

Hello! Probably a very stupid question, but I have very little experience in JS, so I apologize.
There is a website in php and a SQL database where the data is taken from. There is also a JS module that generates a graph. So, it is necessary that the vertices of the graph and the connections between them are formed on the basis of data from the database, and when interacting with these vertices, they give out the necessary information from the database.
How to arrange the reading of this information in the JS module? As far as I understand, having searched the net, this is done through AJAX, but I have not found a detailed description of the mechanism itself anywhere. Could anyone explain or throw material? Thanks

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexander Wolf, 2014-11-04
@hushpar

Create an info.php file, where you make a request from the database, after which (via echo) output the result (in JSON).
In JS (jQuery I think you should):

$.get('/info.php').then(function(data) {
  data = JSON.parse(data);
  // data - это объект, который вы получили в info.php
});

E
Elizaveta Borisova, 2014-11-04
@Elizaveta

You make queries to the database on the server. If there is only php on the server, respectively, using php. And on the client you make requests, as described above.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question