Setting up AJAX in WordPress requires a number of strings in the PHP and JS files to match. This generator gets you started without having to worry about these.
If you have every used one of the handy code generators at GenerateWP you might like this.
The generated code is only a starting point. It submits the AJAX request when the <header> block is clicked on. Obviously you will need to change this to the element and action appropriate for your situation.
Additions to the generator
I didn’t want to create a totally new page or subsite for this feature so I use a shortcode for the form:
[ ajax_generator_form ]
This returns the form (with acceptable sample values) and the empty <pre> blocks for the generated PHP and JS code.
Waiting for PHP code...
The js and php files need to be in the same directory. I have zipped the two files together. You can upload this file with the ‘Upload Plugin‘ button on your ‘Plugins/Add New‘ page.
Download aj-demo.zip plugin