I' am running into some issues from yesterday. Below are all the details that am currently working with.
PHP
$json = array(
'total_cost' => '109.38',
'insurance' => 1
);
echo json_encode( $json );
Console
{"total_cost":109.38,"insurance":"1"}
jQuery
$.post(ajax_url, {'action':action, 'nonce':nonce, 'insurance':insurance}, function( data ){
data = JSON.parse(data);
alert( data.total_cost );
});
The above throws 'undefined'. Any idea what am I doing wrong over here?