Home Forums Add-ons Repeater Field Load Repeater Images via AJAX Reply To: Load Repeater Images via AJAX

  • Any progress with this? I’m trying to do something similar, but pulling values from a repeater field in another page to a popup box on another. I’ve managed to get the first result, using ajax, but I’m unsure how to pull in all of the values.

    This is my code that’s pulling in a single value from the repeater field:

    $field.change(function () { // $field = select dropdown
    	var post_id = $(this).val(); // value of select dropdown = page id where repeater is located
    	var postData = {
    		action : 'data_fetch',
    		'post_id' : post_id
    	var $customList = $(this).closest('.acf-row').find('#modal .checkbox-list-custom'); // element I'm displaying data in (i have multiple divs I want to populate with values)
    	$.post( ajaxurl, postData ).done(function(result) {
    		var resultLower = result.toLowerCase();
    		var result = $('<li><label><input id="test" type="checkbox" value="'+resultLower+'">'+result+'</label></li>');
    		$customList.empty(); // emptying the div of any previous data
    		$customList.append(result); // appending results to div
    	$(this).closest('.acf-row').find('#modal:eq(0)').addClass('visible'); // making relevant div visible after the above has completed
    add_action('wp_ajax_data_fetch', 'data_fetch'); // logged in users
    add_action('wp_ajax_nopriv_data_fetch', 'data_fetch'); // other users
    function data_fetch(){
    	$post_id = filter_input( INPUT_POST, 'post_id' );
    	$array = array();
    	if(have_rows('new_colour', $post_id)) :
    		while(have_rows('new_colour', $post_id)) : the_row();
    			$array = get_sub_field('colour_name', $post_id);
    			foreach ($array as $item) {
    				$array[$array] = $item;
    	wp_send_json($array); //Use WP send json function

    I don’t know whether my partial answer will be of any use, but if you manage to adjust any of it to pull in all values I’d be very interested in seeing what you come up with.