Skip to content Skip to sidebar Skip to footer

Onchange F(x) To Php To Highchart On Same Page

I am continuing a previous question that was asked onclick -> mysql query -> javascript; same page This is my onchange function for a drop down of names. it is called when ea

Solution 1:

I can't believe it, but I finally got it. here is how I used an onchange method to stimulate a MYSQL query and have the Highchart display the result. The major problem was that the returned JSON array was a string that needed to be converted into an INT. The resultArray variable is then used in the data: portion of the highChart.

$(function(){
    $("#awayTeam").change(function(){ 
        $.ajax({
        type: "POST",    
        data: "away=" + $("#awayRunner").val(),
        dataType: "json",
        url: "/getCharts.php",
        success: function(response){
              var arrayLength = response.length;
              var resultArray = [];
              var i = 0;
              while(i<arrayLength){
                  resultArray[i] = parseInt(response[i]);
                  i++;
              }            

In the PHP code, the array must be returned as JSON like this

echo json_encode($awayRunner);

Post a Comment for "Onchange F(x) To Php To Highchart On Same Page"