There is a javascript for building on points and there is a php code for pulling out values from the postgres database. you need to transfer an array of data from the php code to the javascript code
1 answer
Call the necessary php script with JS code, which pulls data from the database, and then returns the result in json. And process the data on js
<?php //Берем данные из базы echo json_encode($data);//$data - данные которые надо вернуть в js ?> ################### #Код JS $.get('/export.php',function(data){ //Построение графика, все данные которые вернул сервер хранятся в data }) Small code template.
PS js- using jquery
- Thank you very much. but the thing is - the first day I just work with javascript and php, not at all in the tooth with my foot as they say. The next question is probably naive to the horror - I did it as they wrote $ .get ('/ ara.php', function (data) {document.write (data);}) produces wild stuff like pseudo-text and at the end of my number. how to fix? this is what drive.google.com/file/d/0B8SBzylZ-emOakNGTnZvclV1Ukk/… shows - anunak
- You are this, why else do you output the data? you probably have a picture on the server being built ... if you build it js, then you should not display the picture, and parse it like this.
$.get('/export.php',function(data){},"json")and if you just show the picture :) then just assign which thread to the img src element of your php script :) - zb ' - Well, I have an array of elements. I want to see how they are stored. just at the conclusion (see the link), first there is a pseudo-graphic ali xz che there, and then my data, that’s what I want to drive into the array - anunak
- Thanks to everyone who helped, figured out the pseudographic - it was necessary to remove the header. - anunak
|
echo json_encode($array)on js use ajax. - zb '