javascript - How to feed dynamic data to static jquery function? -


my source code here below. chart creates made using chartist.js .

<html> <head>      <link rel="stylesheet" href="chartist.min.css">  </head> <body> <h3>chartist test</h3> <br>  <div id="ct-chart5" class="ct-perfect-fourth"></div>  <script src="chartist.min.js"></script> <script src="jquery-2.1.4.min.js"></script> <script>     $(document).ready(function(){          var data = {             series: [5, 3, 4]         };          var sum = function(a, b) { return + b };          new chartist.pie('#ct-chart5', data, {             labelinterpolationfnc: function(value) {                 return math.round(value / data.series.reduce(sum) * 100) + '%';             }         });     }); </script>  </body> </html> 

there var called data inside scripts tags below. thing has predefined values , chat creating static values. how can post dynamic data variable? lets have data retrieving mysql db. want know how feed retrieving data predefined variable dynamically.

i think talking ajax calls, declare variable globally make , ajax call, dynamic data , update variable.

var data; //some code  $.ajax({   url: some_url,   data: some_data,   datatype: some_datatype   //other options,   success:function(jqxhr){     data=jqxhr;//assuming jqxhr dynamic data    }  }) 

Comments

Popular posts from this blog

how to insert data php javascript mysql with multiple array session 2 -

multithreading - Exception in Application constructor -

windows - CertCreateCertificateContext returns CRYPT_E_ASN1_BADTAG / 8009310b -