Lets say I have a Shopping Site, and I want to create a dropdown with all the products. I also want that, when the user select something from the drop down, it will refresh and collect all this product information from the backend, all that through ajax.
To achieve that we should do this
Explanation of each part of the code
wp_enqueue_script( ‘ProductJS’, ‘$filenamepath/priceformat.jquery.js’);
ajaxurl – its the php file of wordpress that handles ajax requests
productAjaxNonce – a unique code generated for each request to improve security
actionProduct – the action, I use this to know, in the backend, when this specific request is being made
Any doubts fell free to post bellow!