I am sending some form data via ajax to a php script in the same page. PHP must process the data and show results in the same page.
I am using this syntax for ajax:
$.ajax
({
    type: "POST",
    url: "",
    data: $("form").serialize(),
    success: function(result)
    {
        updatechart();
       console.log(result);
    }
});  
I am basically trying to update some values in a chart based on data entered in the form and after processed by a php script. I get the whole source of the page when I do console.log(result); and the values are updated in my console after doing this but the chart is not updated. When I view-source the page, the values remain the same. What should I do?
    function updatechart() {
        var json=<?php echo json_encode($GLOBALS['json']); ?>;
        var direct=json['direct'];
        var total=json['total'];
        var referred=total-direct;
        var aid=new Array();
        var count=new Array();
        for(var i=0;i<json['aid'].length;i++) {
            aid[i]=json['aid'][i];
            count[i]=json['count'][i];
        }
    var series = [{
                name : "Referred",
                data: [referred]
            }, {
                name: "Direct",
                data: [direct]
            }];
       for(var i=0; i<aid.length;i++) {
            series.push({
                name: 'AID-'+[aid[i]],
                data: [count[i]]
            })
        }
    var options = {
        chart: {
            renderTo: 'container',
            type: 'column'
        },
        title: {
            text: 'User Source Chart'
        },
        xAxis: {
            categories: ['Users']
        },
        yAxis: {
            min: 0,
            title: {
                text: 'Total users'
            }
        },
        tooltip: {
            pointFormat: '<span style="color:{series.color}">{series.name}</span>: <b>{point.y}</b> ({point.percentage:.0f}%)<br/>',
            shared: true
        },
        plotOptions: {
            column: {
                stacking: 'percent'
            }
        },
            series: series
    };
    chart = new Highcharts.Chart(options); 
}
This is my updatechart() code. The problem is, json value is not updated.
 
     
    