0
I have two functions one prepares the data and makes a call to Ajax and within the call to Ajax has a callback to another function. According to code below:
function retorno_pizza_nacionalidade(result){
console.log(result);
}
function grafico_pizza_nacionalidade(){
var dados = "typepost=grafico_pizza_nacionalidade";
AjaxExecute("php/main_index.php", dados, retorno_pizza_nacionalidade, erro);
}
This all works perfectly, the problem is that I need to pass the return function to the return function inside the tag that is on my page index.php how can I do this with javascript or Jquery. I searched a lot, but I did not find anything of the type. Below the return I need to "paste" inside the tag . Thanks in advance.
$(function () {
Highcharts.chart('pie', {
chart: {
plotBackgroundColor: null,
plotBorderWidth: null,
plotShadow: false,
type: 'pie'
},
title: {
text: 'Frequência Nacionalidade'
},
tooltip: {
pointFormat: '{series.name}: <b>{point.percentage:.1f}%</b>'
},
plotOptions: {
pie: {
allowPointSelect: true,
cursor: 'pointer',
dataLabels: {
enabled: true,
format: '<b>{point.name}</b>: {point.percentage:.1f} %',
style: {
color: (Highcharts.theme && Highcharts.theme.contrastTextColor) || 'black'
}
}
}
},
series: [{
name: 'Brands',
colorByPoint: true,
data: [{name:'Afeganistão', y:50.00},{name:'Brasil',
y:50.00}]
}]
});
});
The second code is the return of the AJAX request or you need to enter this code on the return of the same?
– Woss
The second code is the return of the Ajax request in case that’s what I put to the console.log(result) printar.
– Rayan Pereira de Lima
It is not easier just to return the data and build the chart on
index
even?– Woss
Then it only builds the graph (this is the function of this return) if the code is inside the <script> tag. I could put it inside the index but how would I print it inside the script tag to make it work?
– Rayan Pereira de Lima
I managed to get the code inserted into the page using a jquery append and giving an id to my <script> tag, the problem is that the page is not interpreting the code that was added on the page. it appears there, but it’s like it doesn’t exist. in case I copy the code and put in my html document works perfectly. Detail I had to put in php echo so that the js code was not interpreted. echo htmlspecialchars($Return);
– Rayan Pereira de Lima