Why am i getting this PHP Warning: call_user_func_array() expects parameter 1 to be a valid callback,

548 Views Asked by At

Why am I getting this PHP Warning: call_user_func_array() expects parameter 1 to be a valid callback, function 'process_order' not found or invalid function name in \wp-includes\class-wp-hook.php on line 307

I'm just trying to post this id via Jquery ajax here's the code snippet

$('#buy_now').click(function() {
        $.ajax({
            type : "post",
            // dataType : "json",
            url : `${PROTOCOL + '//' + HOSTNAME}/ssamanila/wp-admin/admin-ajax.php`,
            data : {action: "buy_now", id: 1},
            success: function(response) {
              alert('success');
            }
         }); 

});

on my functions.php

function process_order($args)
{
    $courseId = $_POST['id'];
    var_dump($courseId);
    die();
}
add_action('wp-ajax_buy_now', 'process_order');
add_action('wp-ajax_nopriv_buy_now', 'process_order');

on my browser Network Fetch/XHR admin-ajax.php Preview tab

I'm expecting to get a 1 that's the id I pass via jquery ajax

But I'm getting a 0

and this warning

PHP Warning: call_user_func_array() expects parameter 1 to be a valid callback, function 'process_order' not found or invalid function name in \wp-includes\class-wp-hook.php on line 307

do you have any idea why this is happening

0

There are 0 best solutions below