[Resolved] adding new select field with group members as a value dynamically
-
Hi
I want to be able to add a select field in my group panel extension, and in order to do that I have three files – main plugin file, JavaScript file and php to which I send the request with AJAX post function. The thing is it’s not working
My html element with which I trigger the function
<button class="addnew" onClick="return false" onmousedown="swapContent()">Add Another Field</button> <div id="testing"></div>
the jQuery part
function swapContent() { var url = "select.php"; $.post(url, function(data) { $('#testing').html(data).show(); }); }
And the select.php file
<?php $group_id = bp_get_group_id(); $has_members_str = "group_id=" . $group_id; if ( bp_group_has_members( $has_members_str ) ) : ?> <select name ="member"> <?php while ( bp_group_members() ) : bp_group_the_member(); ?> <option value="<?php bp_group_member_name() ?>"> <?php bp_group_member_name() ?> </option> <?php endwhile; ?> </select> <?php else: ?> <h2>Not in any group.</h2> <?php endif;?>
I have the javascript registered with:
function formAdd_init() { wp_enqueue_script( 'formAdd-js', plugins_url( '/js/formAdd_.js', __FILE__ )); }
Do I need to do smth similar with select.php?
Usually I saw developers getting the content from php file with AJAX using only echo, might it be that $.post gets only echo content?
Thanks in advance
- The topic ‘[Resolved] adding new select field with group members as a value dynamically’ is closed to new replies.