'update fusioncharts when selecting from select

The graph is not plotted if I select the select item .

I pass the selected select by ajax to a php file. The graphic plated only with a constant variable in the php file. I think this is due to the fact that the graphic plated once when the page is opened and is not updated.

app.js:

$(function() {
    $.ajax({
        url: 'chart_data.php',
        type: 'GET',
        success: function(data) {
            chartData = data;
            var chartProperties = {
                "xAxisName": "Type cell",
                "yAxisName": "Number of votes",
                "rotatevalues": "1",
                "theme": "zune"
            };

            apiChart = new FusionCharts({
                type: 'column2d',
                numbersuffix: " Transactions",
                renderAt: 'chart-container',
                width: '500',
                height: '350',
                dataFormat: 'json',
                dataSource: {
                    "chart": chartProperties,
                    "data": chartData
                }
            });
            apiChart.updateChart();
        },
    });
});

stat.php:

<div id="pie">
      <div id="chart-container">The diagram will be displayed here</div>  
</div>
<label for="exampleInputEmail1" class="form-label">Select a marker</label>

<?php
$db = mysqli_connect("", "", "","");
$marker = mysqli_query($db, "SELECT * FROM marker where id_fullimage='$id'");
echo '<select id="id_marker" name="id_marker" class="form-select"  aria-label="Default select example" required onchange="myFunction()">';

while($result = mysqli_fetch_array($marker)){
    echo "<option value=".$result['id_marker'].">".$result['id_marker']."</option>";
 } 

echo "</select>";
?>

<script>
function myFunction(){
  var id_marker = $('#id_marker').val();
  console.log(id_marker);

  $.ajax({
    type: 'POST',
    url: 'chart_data.php',
    dataFormat: 'json',
    data: {
     id_marker:id_marker
    },
    success: function () {
    },
    error: function () {
      alert("ошибка");
    }
  });
};
</script>


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source