I make ajax request that returns data from Word Press .
But as a result, nothing returns to me.
PS: The paths are correct.
Code:
Js:
function ct (x) { $("div.backgroundin").empty() var xhr = new XMLHttpRequest(); xhr.open('GET', '/wp-content/themes/bs/mods/category.php?ct='+x, true); xhr.send(); xhr.onreadystatechange = function () { if (xhr.readyState != 4) return; alert( xhr.responseText ); $("div.backgroundin:empty").html(xhr.responseText); } } PHP:
<?php include('../../../../wp-load.php'); $x = $_GET['ct']; if ( have_posts() ) : query_posts('cat=4'); while (have_posts()) : the_post(); ?> <div class="card" id="card-s"> <div class="card-img-top img-fluid"><?php the_post_thumbnail(array(318,180)); ?></div> <div class="card-body" id="card-body-s"> <h4 class="card-title"><?php the_title(); ?></h4> <p class="card-text"><?php the_excerpt(); ?></p> <a href="<?php the_permalink(); ?>" class="btn btn-primary">Читать дальше</a> </div> </div> <?php endwhile; endif; wp_reset_query(); ?>