There is an issue in the searchSp.php file where the rating script is not being passed to the ajax response.
You can utilize the SDK as mentioned in the comment, eliminating the need for JavaScript in your searchSp.php:
<?php
error_reporting(E_ALL & ~E_NOTICE);
error_reporting(E_ERROR | E_PARSE);
// Utilize API site scope.
define('RW_SDK__API_SCOPE', 'site');
// Adjust the following details according to your site.
define('RW_SDK__SITE_ID', '__YOUR_SITE_ID__');
define('RW_SDK__SITE_PUBLIC_KEY', '__YOUR_SITE_PUBLIC_KEY__');
define('RW_SDK__SITE_SECRET_KEY', '__YOUR_SITE_SECRET_KEY__');
// Include RatingWidget's SDK.
require dirname(__ROOT__) . '/ratingwidget.php';
// Initialize SDK with site details (assuming the SDK is located in the same directory).
$rw_api = new \RatingWidget\Api\Sdk\RatingWidget(
RW_SDK__API_SCOPE,
RW_SDK__SITE_ID,
RW_SDK__SITE_PUBLIC_KEY,
RW_SDK__SITE_SECRET_KEY
);
$item_id = $array["id"]; // Replace it with your rating id.
// To enable Rich-Snippets functionality for ratings,
// designate the rating class as one of these values:
// product, page, blog-post, post, front-post, item
$rating_class = 'product';
$connect = mysqli_connect("localhost", "root", "", "srdatabase");
$search = mysqli_real_escape_string($connect, $_POST["search"]);
$query = "
SELECT * FROM speakers
WHERE speaker_fullname LIKE '%".$search."%'
OR speaker_specialization1 LIKE '%".$search."%'
OR speaker_specialization2 LIKE '%".$search."%'
OR speaker_specialization3 LIKE '%".$search."%'
";
$result = mysqli_query($connect, $query);
if(mysqli_num_rows($result) > 0)
{
while ($array = mysqli_fetch_array($result))
{
$output .= '
<a href="speakerProfile.php?id='.$array["id"].'">
<div class="col-sm-6 col-md-4 wow fadeInDown">
<div class="thumbnail"><img class="speakers-image" src="img/'.$array["speaker_image"].'" style="height:220px; min-width:100%;"/>
<div class="caption" style="height:220px;">
<center>
<h3 class="speakers-name speaker-topics">'.$array["speaker_fullname"].'</h5>
<p class="speakers-name speaker-topics">'.$array["speaker_specialization1"].'</p>
<p class="speakers-name speaker-topics">'.$array["speaker_specialization2"].'</p>
<p class="speakers-name speaker-topics">'.$array["speaker_specialization3"].'</p>
<br><br>
<div class="rw-ui-container rw-class-'.
$rating_class .' rw-urid-'. $item_id.'">
</div>'.
$rw_api->EchoAggregateRating($item_id).'
</center>
</div>
</div>
</div>
</a>
';
}
}
echo $output;
?>
Refer to this link for more information.