多站点模板中的Wordpress Ajax

多站点模板中的Wordpress Ajax,ajax,wordpress,Ajax,Wordpress,我试图在我的wordpress模板中使用ajax。在my functions.php中,我添加了以下代码 function wp_ajax_nopriv_my_special_ajax_call() { // generate the response $response = json_encode( array( 'success' => true ) ); // response output header( "Content-Type: appli

我试图在我的wordpress模板中使用ajax。在my functions.php中,我添加了以下代码

function wp_ajax_nopriv_my_special_ajax_call()
{

    // generate the response
    $response = json_encode( array( 'success' => true ) );

    // response output
    header( "Content-Type: application/json" );
    echo $response;
    exit;
}
add_action('wp_ajax_nopriv_my_special_ajax_call', 'my_special_ajax_call');
在我的模板中,我称之为

jQuery('#category_id').change(function(){
    jQuery.get('/my_wordpress_folder/wp-admin/admin-ajax.php',    {action:'my_special_ajax_call'},function(response,status){ alert(response);alert(status);
    jQuery('select#subcategory_id').html(result);
    });
})

但我得到了-1的回应

该站点是多站点wordpress


请帮助

您需要将函数名从wp\u ajax\u nopriv\u my\u special\u ajax\u call更改为my\u special\u ajax\u call


add操作中的回调需要是执行ajax返回-1的函数的名称,因为您以错误的方式调用它。将函数名更改为my_special_ajax_调用