-
Hello,
I have a custom page template in my WordPress website where I use AJAX call to create a table. Each row of this table contains a cell with a Select element, and one of it’s options suppose to play a video in a lightbox (each row has a different video file to play). I tried long and hard but it doesn’t work for me. Is it possible and if it is, HOW?
Here is my code:
In custom page:
<form action=”<?php echo site_url() ?>/wp-admin/admin-ajax.php” method=”POST” id=”filter”>
// list of links, each loads a table via AJAX to the “response” div
link1, link2, …
</form>
<div id=”response” class=”posts-list”></div>in .js file:
$(‘#filter’).submit(function(){
var filter = $(‘#filter’);
$.ajax({
url:filter.attr(‘action’),
data:filter.serialize(), // form data
type:filter.attr(‘method’), // POST
success:function(data){
$(‘#response’).html(data); // insert data int “response” div
}
});
return false;
});in my functions.php file I have the function filter_function() that returns the requested table. Example output:
“<table class=”no-borders”>
<tr class=”header-back-color”>
<th class=”title-column-width”>Title</th>
<th class=”teacher-column-width”>Teacher</th>
<th class=”date-column-width”>Date</th>
<th class=”duration-column-width”>Duration</th>
<th class=”options-column-width”></th>
</tr><tr>
<td>Some title</td>
<td>My favorite teacher</td>
<td>Sep 4 2017</td>
<td>01:02:23</td>
<td>
<select class=”ddl-options” data-post-id=”501″>
<option value=”” style=”display:none;” selected>Options</option>
<option value=”” class=”watch-video”>Watch Video</option>
<option value=””>Download Video</option>
<option value=””>Download Audio</option>
<option value=””>Download Summary</option>
<option value=””>Download Source Sheet</option>
</select>
</td>
</tr></table><br/>”When I click on “Watch Video” option, I want to see the player in a lightbox (overlay).
I won’t bother you with all the things I already tried to do to achieve this. Please just tell me the working solution for this case.
Thank you!