Home Forums Chart Support How can I use PHP MySQL Dynamic data Reply To: How can I use PHP MySQL Dynamic data


Hi This is my code, I am using Ajax for Displaying Chart

Below is index.php (I am trying to display chart in this page)

$(document).ready(function() {
		var fromDate = document.getElementById('fromDate').value;
		var toDate =  document.getElementById('toDate').value;
			var clickBtnValue = $(this).val();
			//alert(fromDate + ' '+toDate);
			var ajaxurl = 'dbconnect.php',
			data =  {'action': clickBtnValue, 'from': fromDate, 'to' : toDate,  dataType: 'json'};
			$.post(ajaxurl, data,  function (response) {
				var chart = new CanvasJS.Chart("chartContainer", {
					animationEnabled: true,
                    data: [
							type: "spline",
                            dataPoints: response


Below is dbconnect.php (Fetching Data from DB)

$data_points = array();
	while($row = mysql_fetch_array($retval, MYSQL_ASSOC))
		$point = array('label' => $row['date'] , 'y' => $row['value']);
		array_push($data_points, $point); 
	echo json_encode($data_points, JSON_NUMERIC_CHECK);

The response which I received is


Everything was correct, but chart was not displayed. When I give static values, it is working! How to solve this issue?