I have a php file with the following content
----filename.php---
<?php
$text = 'eos';
?>
and I have a js file called app.js with the following content
$(document).ready(function(){
$.ajax({
url: "http://127.0.0.1/swapngo.org/proyecta_json.php",
method: "GET",
success: function(data) {
console.log(data);
var tiempo = [];
var coin = [];
for(var i in data) {
tiempo.push("Date " + data[i].tiempo);
coin.push(data[i].VARIABLE-PHP);
}
var chartdata = {
labels: tiempo,
datasets : [
{
label: 'Coin',
backgroundColor: 'rgba(78, 153, 224)',
borderColor: 'rgba(200, 200, 200, 0.75)',
hoverBackgroundColor: 'rgba(200, 200, 200, 1)',
hoverBorderColor: 'rgba(200, 200, 200, 1)',
data: coin
}
]
};
var ctx = $("#mycanvas");
var barGraph = new Chart(ctx, {
type: 'line',
data: chartdata
});
},
error: function(data) {
console.log(data);
}
});
});
What solution could I use to transport the value of the variable $ text in the php file and use it in my ajax code? I appreciate the help you can give me.
Thanks
I edit my question to show you in more detail what I'm trying to achieve
// peticion ajax
var url = "otro.php";
$.ajax({
url: url,
type: "GET",
success: function (respuesta) {
console.log(respuesta);
}
});
$(document).ready(function(){
$.ajax({
url: "http://127.0.0.1/swapngo.org/proyecta_json.php",
method: "GET",
success: function(data) {
console.log(data);
var tiempo = [];
var coin = [];
for(var i in data) {
tiempo.push("Date " + data[i].tiempo);
coin.push(data[i].console.log(respuesta)); <------
}
var chartdata = {
labels: tiempo,
datasets : [
{
label: 'Coin',
backgroundColor: 'rgba(78, 153, 224)',
borderColor: 'rgba(200, 200, 200, 0.75)',
hoverBackgroundColor: 'rgba(200, 200, 200, 1)',
hoverBorderColor: 'rgba(200, 200, 200, 1)',
data: coin
}
]
};
var ctx = $("#mycanvas");
var barGraph = new Chart(ctx, {
type: 'line',
data: chartdata
});
},
error: function(data) {
console.log(data);
}
});
});
I want to place the value I got from the AJAX query there to generate the Grafica. Thank you for your help.