Hi!
Hope someone can help me out. I have made a meta box view with a static form. When the visitor fills the form I need to grab the values, send it to the bakend, and then back to the meta box view so I can use the values for doing some calculations depending on the values.
This is my functions.php, but what do I need to add so I can grab the json result on the meta bow view like
{{boatlength}}
function calculate_boats() {
// Get values from AJAX-request
$boatlength = $_GET['length'];
$boatwidth = $_GET['width'];
$result = array(
'boatlength' => $boatlength,
'boatwidth' => $boatwidth
);
// Send as Json back to frontend
wp_send_json($result);
}
add_action('wp_ajax_calculate_boats', 'calculate_boats');
add_action('wp_ajax_nopriv_calculate_boats', 'calculate_boats');