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 Custom CSS Selector Field in the  Click Trigger as explained in our Setting Up a Remote Content Popup Doc.

JavaScript

Now that we're setup on the front end, we need to add extra data to the request that will be used inside your AJAX response function. This is done via JavaScript by modifying the jQuery.fn.popmake.rc_user_args array variable. Each popup has a set of values stored in the array using the popup ID as the key.

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:

PHP Function

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 your Remote Content Popup Settings as seen here:

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.

Still need help? Contact Us Contact Us