Form submission in a widget on the dashboard

I have a very simple form inside one of my custom dashboard widgets. I canā€™t quite seem to get the submission to work properly and I havenā€™t been able to figure out why. Without using JavaScript, the form submission refreshes my page and causes me to log back into the panel every time. If I use JavaScript, I can do an e.preventDefault() and an $.ajax call to submit the form, but I canā€™t seem to get the url right for the form submission.

I tried a PHP script in a separate plugin file, but Iā€™m not sure what to make the url for the AJAX call to reach that file from the dashboard. I also tried placing the PHP right in the same template as the widget, and just making the url for the AJAX call an empty string so that it would do a POST request to the same page, but that is causing the request to fail and return a 500 (Internal Server) Error.

Any thoughts on this?

UPDATE1: If I make the URL ā€œsite/plugins/widget/widget.phpā€, the AJAX does a request to
http://site.localhost/panel/site/plugins/widget/widget.php ā€¦ Really I just need a way to access that same exact URL but without the ā€œpanel/ā€ included.

UPDATE2: I tried making the url ā€œā€¦/site/plugins/widget/widget.phpā€, but this returns a 404 Error from a GET request (keep in mind my AJAX is making a POST request) at the url
http://site.localhost/ā€˜path-from-actual-root-to-site-rootā€™/error

Have you tried to get the file in the plugins folder with

<?php echo kirby()->roots()->plugins() . '...' ?>

Just tried this and got a 404 Error. This tries to access a file at
http://site.localhost/ā€˜path-from-actual-root-to-php-fileā€™, but that doesnā€™t work I think because I just need the extension from the site root, not my actual root.