jQuery load() 不显示来自 php 的 echo table | WordPress的

jQuery load() not displaying echo table from php | wordpress

我正在使用 Wordpress,我想显示一个 table,其中包含图片和按钮。 table 应该加载 jquery load() 方法并将结果放入 div.

我得到了我想要的结果,但它没有显示在 div 中。就在这里: here.

例如,当我将带有文本但没有任何 php 的 H2 放入 php 文件时,它就会显示出来。

脚本

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script type="text/javascript">
function GetURLParameter(sParam)
{
    var sPageURL = window.location.search.substring(1);
    var sURLVariables = sPageURL.split('&');
    for (var i = 0; i < sURLVariables.length; i++) 
    {
        var sParameterName = sURLVariables[i].split('=');
        if (sParameterName[0] == sParam) 
        {
            return sParameterName[1];
        }
    }
}
jQuery(document).ready(function(){
    var $id = GetURLParameter('id');
    var urlGetItem = "getItems.php/?id=" + $id;
    jQuery('#load_surveys').load(urlGetItem);
});
</script>

HTML

<div id="load_surveys"></div>

PHP

<?php

include_once 'db.php';
require ('../wp-blog-header.php');

global $wpdb;
global $current_user;

get_currentuserinfo();
$userId = $current_user->ID;

$id = $_GET['id'];
$result = mysqli_query($conn,"SELECT * FROM f5_users JOIN COMPARISONFOLDER ON COMPARISONFOLDER.USER_ID = f5_users.ID JOIN ITEM ON ITEM.COMPARISONFOLDER_ID LIKE COMPARISONFOLDER.COMPARISONFOLDER_ID WHERE COMPARISONFOLDER.COMPARISONFOLDER_ID LIKE $id AND f5_users.ID LIKE $userId");

echo "<table border='1'>
<tr>
<th>Item</th>
<th>Delete</th>
</tr>";

while($row = mysqli_fetch_array($result))
{
echo "<tr>";
echo '<td><img src="data:image/jpeg;base64,'.base64_encode($row['ITEM']).'" width="500" height="auto"/></td>';
echo "<td><button type='button' onclick='deleteItem(".$row['ITEM_ID'].", $id)'>Testing Script</button></td>";
echo "</tr>";
}

echo "</table>";
?>

如果你做 console.log('id',$id) 和 console.log('url,urlGetItem)

jQuery(document).ready(function(){
    var $id = GetURLParameter('id');
    console.log('id',$id);
    var urlGetItem = "getItems.php/?id=" + $id;
    console.log('url,urlGetItem);
    jQuery('#load_surveys').load(urlGetItem);
});

PHP

$markup = "<table border='1'>
<tr>
<th>Item</th>
<th>Delete</th>
</tr>";

while($row = mysqli_fetch_array($result))
{
$markup .= "<tr>";
$markup .='<td><img src="data:image/jpeg;base64,'.base64_encode($row['ITEM']).'" width="500" height="auto"/></td>';
e "<td><button type='button' onclick='deleteItem(".$row['ITEM_ID'].", $id)'>Testing Script</button></td>";
$markup .= "</tr>";
}

$markup .= "</table>";
echo $markup;