Home Forums General Issues Using .load() Results in 'Uncaught Error'


Using .load() Results in 'Uncaught Error'

  • Hello,

    I have a setup that’s rather unique as far as using ACF goes, and I think I’m trying to do something that’s either not allowed, or I’m simply doing things incorrectly.

    The situation: I have a form on my client’s site that contains a <select> called #campus. When an <option> is selected from #campus, a second (conditional) <select> called #program appears, and contains a list of <option>s that is unique to the selected #campus <option>.

    Because of certain constraints (I’m picking this site up from a previous developer), I built out a jQuery function that uses .load() to load a .php file into #program that contains the appropriate <option>s based on whatever #campus <option> the user selects. Up to this point, everything has been working properly.

    Here’s where it started to break: In an attempt to be able to add/remove/edit the #program <option>s from the WP backend, I created an ACF Repeater and added it to one of the .php files that contains a set of #program <option>s. The code looks like this:

    if( have_rows('programs', 'option') ):
    while ( have_rows('programs', 'option') ) : the_row(); ?>
    <option value="<?php the_sub_field('program_value', 'option'); ?>"><?php 
    the_sub_field('program_copy', 'option'); ?></option>
    <?php endwhile;

    So, basically, I’m trying to use jQuery to .load() in a .php file that contains ACF Repeater code and it’s returning the following error: Uncaught Error: Call to undefined function have_rows()

    Any help? I hope I was able to explain everything clearly.

  • The problem is that nothing in WP is loaded if you are trying to load the content of a specific PHP file using AJAX.

    In order to have access to all WP and plugin function you must make all request through /wp-admin/admin-ajax.php, setting the required “action” and creating the needed WP filters rather than requesting a specific file. This page explains AJAX in WP, it says AJAX in Plugins, but the information is relevant to all AJAX requests in WP.

  • Sorry, you wrote ‘this page’ but I don’t see a hyperlink. Did you forget to add one or am I misunderstanding? Either way, thank you for the help, it has definitely steered me in the right direction.

Viewing 4 posts - 1 through 4 (of 4 total)

The topic ‘Using .load() Results in 'Uncaught Error'’ is closed to new replies.