Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

131
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!