onclick -> mysql query -> javascript; same page

后端 未结 4 1268
自闭症患者
自闭症患者 2021-01-29 03:41

I need button to begin a mysql query to then insert the results into a javacript code block which is to be displayed on the same page that the button is on. mysql queries come f

4条回答
  •  感情败类
    2021-01-29 04:18

    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

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

    echo json_encode($awayRunner);

提交回复
热议问题