๐:0
As I see the solution could be simple:
- Send a POST HTTP request to your PHP file.
- Validate you have a POST request with an if sentence and isset($_POST)
- Prepare or extract the data, and create an associative array like the next one:
$label_data = ["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"]; $revenue_data = [105,85,55,68,72,8,0,0,0,0,0,0]; $cost_data = [41,32,22,23,26,3,0,0,0,0,0,0]; $data = [ 'label' => $label_data, 'revenue' => $revenue_data, 'cost' => $cost_data ]; echo json_encode($data);
if you have data divided between arrays just merge them with array_merge and store the result in a new variable
$label_first = ["Jan","Feb","Mar","Apr","May","Jun"]; $label_second = ["Jul","Aug","Sep","Oct","Nov","Dec"]; $label_data = array_merge($label_first, $label_second );
- Finally catch the response in your $.ajax and, perform the action you want to do the data.
I hope this information could be useful for you.