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

121
Views
array always empty after came out from ajax call
    var data123 =[];

 function createChart() {
                $.ajax({
                    type: 'GET',
                    url: "",
                    dataType: 'json',
                    success: function (data) {
                        obj["source"] = "Pending";
                        obj["percentage"] = data.totalFiles;
                        data123.push(obj);
                    }
                });
                var x = data123.length; // undefined

                $("#chart").kendoChart({
                    title: {
                        text: "Break-up of Spain Electricity Production for 2008"
                    },
                    legend: {
                        position: "bottom"
                    },
                    dataSource: {
                        data: data123
                    }
                });
            }
            $(document).ready(createChart);
            $(document).bind("kendo:skinChange", createChart);

I have a function like this

What am I trying to do is

  1. first load data and set it into a array .
  2. then create a chart with that array data.

debugging result :- after ajax call success data123 store with obj and length is 1.

when it entered to createChart function data123 length became zero.

my expected result :- in first ajax call I need to set array . that global array i need to use in createChart function.

please support ,what did i wrong ?

about 4 years ago · Juan Pablo Isaza
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!