I have added a button on a custom post type Add New page to get some API data when clicked.
When the data is returned, I would like to update field Taxonomy within the custom post type. Is there a way that I can update the fields with AJAX/jQuery?
I have tried this by finding the field in jQuery and use val() to be able to update it, however this has not worked.
$.post(
ajaxurl,
{
action: 'get_vehicle_data',
nonce: nonce
},
function( response ){
if ( 'OK' == response ) {
$('#acf-field_588f336aabaa6-input').val('2012');
}
else {
alert( 'Something went wrong, try again' );
}
}
);
I would like to update taxonomy fields with the data that comes back from the API.