Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

133
Visualizações
Update javascript chart based on ajax response

I am trying to populate my javascript chart data based on ajax data from database. The chart in question is called apex chart if that helps. I am submitting a form via ajax and getting a result as follows:

type: "POST",crossDomain: true, cache: false,
data: loginStringnew,
success: function(data2){
$("#appyrpen").html(data2);
             

Now instead of displaying the result in $("#appyrpen").html(data2);

I would like to update a javascript chart code which looks like this :

 if($('#sales_chart').length>0){var
columnCtx=document.getElementById("sales_chart"),columnConfig={colors
['#0CE0FF','#1B5A90','#DFE5FC'],series:[{name:"Completed",type:"column",data:[4,2.8,5,2,3.2,1.2,2,3,2,3.5,5,2]}

The data element of the chart is this: data:[4,2.8,5,2,3.2,1.2,2,3,2,3.5,5,2]} and I am trying to populate it with the ajax success result.

Thanks for all the help.

about 4 years ago · Santiago Gelvez
1 Respostas
Responde à pergunta

0

Although not an AJAX solution, Instead of trying to populate javascript based on ajax response, you can use php.Put your php code and javascript on the same page and then populate the dataset data:[4,2.8,5,2,3.2,1.2,2,3,2,3.5,5,2] using data:[<?php echo $phpresult ?>]

So whatever response you were getting in ajax below, you can get it in php query and assign it to $phpresult and then echo that result variable in data placeholder. Hope that makes sense.

success: function(data2){
$("#appyrpen").html(data2);
about 4 years ago · Santiago Gelvez Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda