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