Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7055199
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T03:43:11+00:00 2026-05-28T03:43:11+00:00

My issue revolves around having to click a button twice to populate the results

  • 0

My issue revolves around having to click a button twice to populate the results desired. I am using HighCharts to draw a chart, but the updateTime3Period() function must be called twice before the chart is properly displayed. Below I have included all my code, except for the updateTime6Period() function, since it is the same as updateTime3Period() in most ways. They both have the same issue. I would like to have the button be clicked once, and then populate the desired chart. I apologize for the lengthy post. Thank you in advance! Note: This does work if updateTime3Period() is clicked twice.

HTML:

<div id="timelinePeriods">
    <ul class="timeSelection">
        <li><a href="#" onclick="updateTime6Period();" > Past 6 Periods</a></li>
        <li><a href="#" onclick="updateTime3Period();"> Past 3 Periods</a></li>
    </ul>
</div>

JS/AJAX for updateTime3Period:

function updateTime3Period() {
    timeFrameUpdate = 'Past 3 Periods';
    displayParam();

    $.ajax({
        url: 'PHP/getValues.php',
        type: 'post',
        data: {
            type: "A",
            type2: B,
            type3: C,
            type4: D,
            type5: E,
            type6: F,
            type7: "getChartCurr"
        },

        success: function(response2) {
            obj2 = JSON.parse(response2);

        }

    });

    $.ajax({
        url: 'PHP/getValues.php',
        type: 'post',
        data: {
            type: "A",
            type2: B,
            type3: C,
            type4: D,
            type5: E,
            type6: F,
            type7: "getChartPrev"
        },

        success: function(response3) {
            obj3 = JSON.parse(response3);

        }

    });

    updateCharts(obj2, obj3, measureUpdate);
}

Functions that are called above (same file):

function displayParam() {
    document.getElementById("params").innerHTML = timeFrameUpdate;
}

function updateCharts(data1, data2, measureData) {

} else if (timeFrameUpdate == 'Past 6 Periods') {
    updateSixMonthPeriodChart(data1, data2, measureData);
} else if (timeFrameUpdate == 'Past 3 Periods') {
    updateThreeMonthPeriodChart(data1, data2, measureData);
}

HighCharts Graph:

function updateThreeMonthPeriodChart(data1, data2, measureData) {

    var measureValue = data1["graph"];
    var measureValuePrev = data2["graphPrev"];
    var changeValue = new Array();

    for (i = 0; i < 3; i++) {
        measureValue[i] = parseInt(measureValue[i]);
        changeValue[i] = (parseInt(measureValue[i]) - parseInt(measureValuePrev[i])) / parseInt(measureValuePrev[i])
    }
    var chart1; // globally available
    $(document).ready(function() {
        chart1 = new Highcharts.Chart({
            chart: {
                renderTo: 'myChart',
            },
            title: {
                text: 'Sales and Percent Change vs. Last Year - Past 3 Periods'
            },
            xAxis: {
                categories: [1, 2, 3],
                title: {
                    text: 'Period'
                },
            },
            yAxis: [{
                labels: { //Right y-axis
                    formatter: function() {
                        return Highcharts.numberFormat(this.value, 1, '.', ',') + '%';
                    }
                },
                title: {
                    text: '% Change'
                },
                opposite: true
            },
            { //Left y-axis
                labels: {
                    formatter: function() {
                        return '$' + Highcharts.numberFormat(this.value, 0, '', ',');
                    }
                },
                title: {
                    text: 'Sales ($)'
                }
            },
            ],
            series: [{
                name: 'Sales',
                data: [measureValue[0], measureValue[1], measureValue[2]],
                color: '#363534',
                //Charcoal
                yAxis: 1,
                type: 'column'
            },
            {
                name: '% Change',
                data: [changeValue[0], changeValue[1], changeValue[2]],
                color: '#E17000',
                //Pumpkin
                //yAxis: 2,
                type: 'spline'
            }]
        });
    });
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T03:43:11+00:00Added an answer on May 28, 2026 at 3:43 am

    It might be cause of your ajax request, it didn’t complete at first click.in the next click it get the result from the catch and runs faster.

    try this :

    function updateTime3Period() {
        timeFrameUpdate = 'Past 3 Periods';
        displayParam();
    
            $.ajax({
            url : 'PHP/getValues.php',
            type : 'post',
            data : {
                type : "A",
                type2 : B,
                type3 : C,
                type4 : D,
                type5 : E,
                type6 : F,
                type7 : "getChartCurr"
            },
    
            success : function (response2) {
                obj2 = JSON.parse(response2);
                         $.ajax({
                               url : 'PHP/getValues.php',
                               type : 'post',
                               data : {
                            type : "A",
                            type2 : B,
                            type3 : C,
                            type4 : D,
                            type5 : E,
                            type6 : F,
                            type7 : "getChartPrev"
                            },
                               success : function (response3) {
                            obj3 = JSON.parse(response3);
                            updateCharts(obj2,obj3,measureUpdate);  
                               }
                        });
            }
    
        });
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I suspect my issue revolves around a poor understanding of how custom event handlers
I am having an issue with playing music using XNA, and this issue is
I think my question revolves around me not having a comfortable grasp of page
The issue is there is a database with around 20k customer records and I
Our issue is that our project has files being downloaded using wget to the
My issue is not able to render the chart in .tpl file. The following
I have an issue with using declarative helpers in the App_Code directory. I created
My question revolves around CSS Fixed Layout vs a Float Layout that extends to
I've run into the issue of using a UIBarButtonItem with a custom color. Everything
Im having an issue with an MDX query, and I think it boils down

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.