Plugin is used to add features to the site without modifying the core code.
While building plugin you can also use AJAX to save the form after submit, retrieve data from MySQL database, file upload, etc.
In the plugin, AJAX is implemented as same as implemented on the theme.
In this tutorial, I show how you can create a custom plugin and send an AJAX request in WordPress.