使用PHP生成的按钮生成POST请求,该按钮使用参数调用javascript函数

First of all, sorry for the weird title! Currently im facing the following problem:

I have a PHP script which creates a HTML button

echo '<input type="button" id="$entryID" name="change_title" value="change title" onclick="sendRequest(sendRequest($type, $entryID));" />';

This button should call a script, which creates a post request with the parameter

$type //is used to recognize which mysqli table should be adressed
$entryID //is used to recognize which entry in table sould be adressed

I know that I can not create a post request with javascript because its for front-end developement. So I have done some researches and found AJAX. So im never realy used it. But I tried to create a post request like this (in the same file):

<script>
    // t = type & i = ID
    function sendRequest(t, i){

        var request = $.ajax({
        type: "POST",
        url: "admin_page.php",
        data: {"type": t, "id": i},
        success: function(){
            console.log('request via AJAX');
        }
    });

        return request;
    }
</script>

After the script has run I use the following php script to check if it has worked:

if(isset($_POST['type'])){
    if(isset($_POST['id'])){
        printf('Post request sent');
    }
}

I have checked the AJAX and the javascript documentations and have not found anything. It this process even possible? What am I doing wrong?

Thanks in advance.

I edited this answer after realizing that this was part of an echo statement. This should work:

echo '<input type="button" id="'.$entryID.'" name="change_title" value="change title" onclick="sendRequest('.$type.','.$entryID.'));" />';

Also I would advise against calling the JS function with variables generated via PHP. It is not elegant. Put your variables as data-* attributes and use JS to pull these attributes