I have the following code in a JS file inside a JS folder in my WP theme:
jQuery('#tarieven-submit').on('click', function(event) {
event.preventDefault();
var dest = jQuery('#destination').val();
var type = jQuery('input[name=taxiType]:checked', '#distance_form').val()
if (jQuery.trim(dest) != '' && type != '') {
jQuery.post('../HTA/wp-content/themes/HTA/ajax/tarieven.php', { destination: dest, type: type}, function(data) {
jQuery('#result').text(data);
});
}
});
I cannot get this to work even though the file that is being posted to is located in the correct folder. I'm guessing it has something to with a wrong AJAX call. But I cannot seem to find how to do this properly. For example, I've seen I need to do an AJAX call in admin-ajax.php, however, how do I add my custom code there?