I asked a question earlier today with little luck: AJAX within a foreach loop
i was put on the right path but the answer provided has got me more confused than ever. Whe
there have been 2 problems in your PHP script:
1. the function was not called
2. the return-value of the function was not echoed.
(in order to respond to an AJAX call, the called url always needs to output something - JSON in the most cases. AJAX can't access PHPand thus can't read PHP return values.)
here is the fixed version:
function update_this_func($remove_option, $uservideo_id){
global $wpdb;
$wpdb->query("UPDATE " . $wpdb->prefix."uservideo
SET is_removed =" . $remove_option . "
WHERE uservideo_id =" . $uservideo_id );
return json_encode(['status' => 'Updated!']); // return status as json
}
echo update_this_func($_POST['remove_option'], $_POST['uservideo_id']);