如何在Wordpress中的自定义插件的管理面板中创建一个表的实时搜索?

I'm new to Wordpress plugin developement, and I'm trying to create a live search for a HTML table in admin panel for my Wordpress plugin, but I have no idea how to refer the search to the table in the panel. My guess the problem is with the url in the jQuery AJAX call.

When I put the url of my index.php file, it just copies the whole wordpress page.

Here is the code:


    function ecommerce_plugin_menu(){
        $connection = mysqli_connect('localhost', 'root', '', 'wordpresssite') or die("couldn't connect");
        echo "<input type='text' name='search_text' id='search_text' />";
        echo "<div id='result'>";
        echo "<table style='border: 1px solid black'>"; // start a table tag in the HTML
        echo "<tr><th><a href='admin.php?page=ecommerce&sort=first'>First Name</a></th><th><a href='admin.php?page=ecommerce&sort=last'>Last Name</a></th><th><a href='admin.php?page=ecommerce&sort=address'>Address</a></th><th><a href='admin.php?page=ecommerce&sort=email'>E-mail</a></th></tr>";
        $query = "SELECT * FROM wp_ecommerce_fs";
    $result = mysqli_query($connection, $query);

        while($row = mysqli_fetch_array($result)){   //Creates a loop to loop through results
        echo "<tr><td>" . $row['first_name'] . "</td><td>" . $row['last_name'] . "</td><td>". $row['address'] . "</td><td>" . $row['email'] . "</td></tr>";  
        }
        echo "</table>";
        echo "</div>";
        echo "<script>
        jQuery(document).ready(function(){
            jQuery('#search_text').keyup(function(){
                var txt= jQuery(this).val();
                if(txt != '')
                {
                jQuery.ajax({
                        url: plugin_dir_url('index.php'),
                        method:'post',
                        data:{search:txt},
                        dataType:'text',
                        success:function(data)
                        {
                            jQuery('#result').html(data);
                        }
                    });
                }
                else
                {
                    jQuery('#result').html('');

                }
            });
        });</script>";
    }

I want to search the contents of the HTML table directly if whatever in the table matches the user input. What would be the correct url in AJAX call?

Thanks.