jQuery load Google Visualization API with AJAX

后端 未结 10 2237
栀梦
栀梦 2020-12-24 02:17

There is an issue that I cannot solve, I\'ve been looking a lot in the internet but found nothing.

I have this JavaScript that is used to do an Ajax request by PHP.

10条回答
  •  梦毁少年i
    2020-12-24 02:58

    I remember when I used a Google API it explicitly said to initialize the load first off. So maybe keep the google.load function out of the AJAX, and then just keep calling the second part of your function on success:

    //Straight Away!
    google.load('visualization', '1', {'packages': ['annotatedtimeline']}); 
    
    $(document).ready(function(){
        // Get TIER1Tickets                 
        $("#divTendency").addClass("loading");
    
        $.ajax({
            type: "POST",
            url: "getTIER1Tickets.php",
            data: "",
            success: function(html){
                // Succesful, load visualization API and send data
                google.setOnLoadCallback(drawData(html)); 
            }
        });  
    });
    

提交回复
热议问题