javascriptjqueryhighchartshighslide

Posting data to the server from highchart points


I am trying to post data from highcharts.

  point: {
    events: {
        click: function (e) {
            hs.htmlExpand(null, {
                pageOrigin: {
                    x: e.pageX || e.clientX,
                    y: e.pageY || e.clientY
                },
                headingText: this.series.name,
                maincontentText: Highcharts.dateFormat('%A, %b %e, %Y', this.x) + ':<br/> ' +
                    this.y + ' visits ' + '<div>'+'<button onclick="posting(this.y)">'+'send report' +'</button>'+'</div>',
                width: 200
            });
        }
    }
}

I am calling a function on clicking the button and I want to send data to it. How can we send this.y to posting() function so that we get current point value in the function. This fiddler is showing the undefined in alert. How can I achieve the this.y value there. Click on the points in the chart then click the send report button and you will get my problem.


Solution

  • It will solve the problem if you use

    <button onclick="posting('+this.y+')">'+'send report' +'</button>'+'</div>'
    

    instead of

    <button onclick="posting(this.y)">'+'send report' +'</button>'+'</div>'