Remote Content -- AJAX Type Introduction
Remote Content AJAX Functionality Example
Setup on the Front End
First, setup whatever it is you'll be targeting on the front end, whether that is an image, text, header, etc.
Target Your Front End Element(s)
As always with Remote Content, you have to target each element on the front end that you setup so that, when clicked, the element(s) will trigger the popup. Do this using the 'Extra CSS Selectors' field in the Click Trigger as explained in our Setting Up a Remote Content Popup document.
The following JS code shows how to add parameters just before the request is made for popup 36287. We've also applied a wrapper to the code so that we're able to implement it in the WordPress Admin using a plugin like Simple Custom CSS/JS:
The custom and name parameters can then be passed along in the AJAX function to customize the content. We like to use a plugin like My Custom Functions to input the function in the WP Admin so that it runs seamlessly on the front end:
Adding the Function Name to Remote Content
Now all that's left is to enter 'popmake_remote_content_ajax' as the function name in the Remote Content Area box (shortcode option settings).
With these settings and code in place, your popup's content will be:
Hello Daniel, you chose option 123
As you can see, this functionality allows you ultimate flexibility because you're not actually inputting content into the WYSIWIG Popup Content Editor, but dynamically generating content using code. You can pass parameters based on the button/link they clicked, user details, or any other possibilities you can come up with.