Хочу получить видео в модале от ajax. Я получаю это видео из пользовательского поля в Wordpress. Мой код работает на localhost и на сервере. Он перестал работать без каких-либо изменений на сервере и возвращает 0. В консоли нет ошибок.
Хотя это все еще хорошо работает на localhost.
Ниже приведен файл function.php.
add_action('wp_ajax_nopriv_getTheVideo', 'getTheVideo');
add_action('wp_ajax_getTheVideo', 'getTheVideo');
function getTheVideo(){
$args = array('post_type' => 'page');
query_posts($args);
while ( have_posts() ) : the_post();
if( have_rows('builder_page') ){
while ( have_rows('builder_page') ) : the_row();
if( get_row_layout() == 'introduction_section' ){
$full_video = get_sub_field('full_video', get_the_ID());
$upload_full_video = $full_video['upload_full_video'];
if($upload_full_video) {
$modal = "<video playsinline controls>
<source src=" . $upload_full_video['url'] . " type='video/mp4'>
</video>";
echo $modal;
die();
}else{
echo "<div class='text-center p-4'><h2> Sorry ! No Video :( </h2>
</div>";
}
}
endwhile;
}
endwhile;
}
Ниже приведен код ajax:
jQuery(document).ready(function($) {
$('#showModal').on('click' , function(){
$.ajax({
url : v_Ajax.ajax_url,
type: 'POST',
data: {action:'getTheVideo'},
success : function (response) {
$('#resData').html(response);
},
error : function(){
$('#resData').html("<div class='text-center p-4'><h2> Sorry ! No Video :( </h2></div>");
},
});
});
});