0
Q:

ajax call too functions.php

    var ajaxurl = 'https://example.com/wp-admin/admin-ajax.php';
    $.ajax({
        url: ajaxurl,
        type: 'post',
        data: { action: 'register_user' ,"username": "arshia"},
        success: function(response) { console.log(response); }
    });
1
<?php
    // ajax call to this function
    function register_user()
    {
        $username = $_POST['username'];
        echo $username;

        die();
    }

    add_action('wp_ajax_register_user', 'register_user');
    add_action('wp_ajax_nopriv_register_user', 'register_user');
    
?>
1

New to Communities?

Join the community