- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我的问题是,当我使用 ajax 函数进行搜索和过滤时,我使用的星级评分插件 ( http://rating-widget.com/) 没有显示。
但是当我使用过滤器和搜索功能时,星级评分消失了。这张图片是当我在下拉列表中选择动机时
这是主页的代码,其中包含图像、搜索和过滤功能
<div id="div-search" class="wow fadeInDown">
<div class="form-group inline-buttons">
<div>
<div class="input-group">
<span class="input-group-addon" style="min-width:150px;">Search</span>
<input type="text" name="search_text" id="search_text" placeholder="Search for name or topic" class="form-control"/>
</div>
</div>
</div>
<div class="input-group">
<span class="input-group-addon" style="min-width:150px;">Filter</span>
<select name="sortdrpdwn" id="sortdrpdwn" class="form-control" style="width:100%;">
<option value="all">All</option>
<option value="motivational">Motivational</option>
<option value="technology">Technology</option>
<option value="business">Business</option>
<option value="leadership">Leadership</option>
<option value="innovation">Sales</option>
<option value="entertainment">Entertainment</option>
<option value="healthcare">Health Care</option>
</select>
</div>
<br>
<div id="order_table" style="overflow-x:auto;"></div>
<script>
$(document).ready(function()
{
$('#sortdrpdwn').change(function()
{
var sortdrpdwn = $('#sortdrpdwn').val();
$.ajax({
url:"filterSp.php",
method:"POST",
data:{filter:sortdrpdwn},
success:function(data)
{
$('#order_table').html(data);
}
});
});
});
</script>
<script>
$(document).ready(function()
{
$('#search_text').keyup(function()
{
var searchtext = $('#search_text').val();
$.ajax({
url:"searchSp.php",
method:"POST",
data:{search:searchtext},
success:function(data)
{
$('#order_table').html(data);
}
});
});
});
</script>
<script>
$(document).ready(function(){
load_data();
function load_data(page)
{
var sortdrpdwn = $('#sortdrpdwn').val();
var searchtext = $('#search_text').val();
if(searchtext != '')
{
$.ajax({
url:"searchSp.php",
method:"POST",
data:{search:searchtext},
success:function(data)
{
$('#order_table').html(data);
}
});
}
else
{
$.ajax({
url:"filterSp.php",
method:"POST",
data:{filter:sortdrpdwn},
success:function(data)
{
$('#order_table').html(data);
}
});
}
}
});
</script>
filterSp.php 这是我使用过滤器下拉列表时调用的 php 文件,里面是用于星级评分的插件 java 脚本。
<?php
error_reporting(E_ALL & ~E_NOTICE);
error_reporting(E_ERROR | E_PARSE);
$connect = mysqli_connect("localhost", "root", "", "srdatabase");
if(isset($_POST['search_text']))
{
$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."%'
OR speaker_specialization4 LIKE '%".$search."%'
OR speaker_specialization5 LIKE '%".$search."%'
";
}
else
{
$filter = mysqli_real_escape_string($connect, $_POST["filter"]);
if($filter == "all")
{
$query = "SELECT * FROM speakers";
}
else if($filter == "motivational")
{
$query = "SELECT * FROM speakers WHERE speaker_specialization1 = 'motivational' OR speaker_specialization2 = 'motivational' OR speaker_specialization3 = 'motivational' ";
}
else if($filter == "technology")
{
$query = "SELECT * FROM speakers WHERE speaker_specialization1 = 'technology' OR speaker_specialization2 = 'technology' OR speaker_specialization3 = 'technology' ";
}
else if($filter == "business")
{
$query = "SELECT * FROM speakers WHERE speaker_specialization1 = 'business' OR speaker_specialization2 = 'business' OR speaker_specialization3 = 'business' ";
}
else if($filter == "leadership")
{
$query = "SELECT * FROM speakers WHERE speaker_specialization1 = 'leadership' OR speaker_specialization2 = 'leadership' OR speaker_specialization3 = 'leadership' ";
}
else if($filter == "innovation")
{
$query = "SELECT * FROM speakers WHERE speaker_specialization1 = 'innovation' OR speaker_specialization2 = 'innovation' OR speaker_specialization3 = 'innovation' ";
}
else if($filter == "entertainment")
{
$query = "SELECT * FROM speakers WHERE speaker_specialization1 = 'entertainment' OR speaker_specialization2 = 'entertainment' OR speaker_specialization3 = 'entertainment' ";
}
else if($filter == "healthcare")
{
$query = "SELECT * FROM speakers WHERE speaker_specialization1 = 'healthcare' OR speaker_specialization2 = 'healthcare' OR speaker_specialization3 = 'healthcare' ";
}
}
$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:150px; min-width:100%" >
<center>
<h3 class="speakers-name">'.$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>
//The div where the star rating will show
<div class="rw-ui-container" data-urid='.$array["id"].'></div>
</center>
</div>
</div>
</div>
</a>
';
}
}
echo $output;
?>
// Star rating javascript
<script type="text/javascript">(function(d, t, e, m){
// Async Rating-Widget initialization.
window.RW_Async_Init = function(){
RW.init({
huid: "374760",
uid: "43310efaa801e10e1e02debca5f5b237",
source: "website",
options: {
"size": "medium",
"style": "oxygen",
"isDummy": false
}
});
RW.render();
};
// Append Rating-Widget JavaScript library.
var rw, s = d.getElementsByTagName(e)[0], id = "rw-js",
l = d.location, ck = "Y" + t.getFullYear() +
"M" + t.getMonth() + "D" + t.getDate(), p = l.protocol,
f = ((l.search.indexOf("DBG=") > -1) ? "" : ".min"),
a = ("https:" == p ? "secure." + m + "js/" : "js." + m);
if (d.getElementById(id)) return;
rw = d.createElement(e);
rw.id = id; rw.async = true; rw.type = "text/javascript";
rw.src = p + "//" + a + "external" + f + ".js?ck=" + ck;
s.parentNode.insertBefore(rw, s);
}(document, new Date(), "script", "rating-widget.com/"));
</script>
searchSp.php 这是我使用搜索功能时调用的 php 文件,里面是用于星级评定的插件 java 脚本。
<?php
error_reporting(E_ALL & ~E_NOTICE);
error_reporting(E_ERROR | E_PARSE);
$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" data-urid='.$array["id"].'></div>
</center>
</div>
</div>
</div>
</a>
';
}
}
echo $output;
?>
<script type="text/javascript">(function(d, t, e, m){
// Async Rating-Widget initialization.
window.RW_Async_Init = function(){
RW.init({
huid: "374760",
uid: "43310efaa801e10e1e02debca5f5b237",
source: "website",
options: {
"size": "medium",
"style": "oxygen",
"isDummy": false
}
});
RW.render();
};
// Append Rating-Widget JavaScript library.
var rw, s = d.getElementsByTagName(e)[0], id = "rw-js",
l = d.location, ck = "Y" + t.getFullYear() +
"M" + t.getMonth() + "D" + t.getDate(), p = l.protocol,
f = ((l.search.indexOf("DBG=") > -1) ? "" : ".min"),
a = ("https:" == p ? "secure." + m + "js/" : "js." + m);
if (d.getElementById(id)) return;
rw = d.createElement(e);
rw.id = id; rw.async = true; rw.type = "text/javascript";
rw.src = p + "//" + a + "external" + f + ".js?ck=" + ck;
s.parentNode.insertBefore(rw, s);
}(document, new Date(), "script", "rating-widget.com/"));</script>
最佳答案
在 searchSp.php 中,您没有将评级脚本传递给 ajax 响应。
就像我在评论中所说的那样,您可以使用 sdk,如果是这样就不需要 javascript,您的 searchSp.php 会像
<?php
error_reporting(E_ALL & ~E_NOTICE);
error_reporting(E_ERROR | E_PARSE);
// Use API site scope.
define('RW_SDK__API_SCOPE', 'site');
// Modify the following definitions to your site details.
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';
// Init SDK with your site details (assumes that the SDK located in same folder of this example).
$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 that with your rating id.
// If you want the rating to work with Rich-Snippets,
// set the rating class to one of the following 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;
?>
参见 this ->
关于javascript - 评分小部件未显示在 ajax 调用中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46279997/
当我搜索“iphone”时,我有以下记录和分数 - 记录1: 字段名称 - 显示名称:“iPhone” 字段名称 - 名称:“iPhone” 11.654595 = (MATCH) sum of:
Types Description: parent type 1)Parent Type: "product" 2)childType : "ratings" 问题描述:我有一个es查询(q
如果您使用 Freebase 搜索按名称获取任何实体的匹配项,您将获得按 relevance score 排序的结果.例如尝试 Taj Mahal . 我正在尝试使用 Freebase 数据转储获得类
我试图根据多个不同的标准给不同的城市打从 1 到 5 的“分数”,最终将分数相加并决定哪个城市最好。 表“international_tobacco_alcohol”包含居民用于酒精和烟草的收入百分比
我有一年中任何一个季度的索引(“index-2015.1”,“index-2015.2”...) 我在每个索引上有大约 3000 万个文档。 文档有一个文本字段('title') 我的文档排序方式是(
我有一个数组,我想根据为数组中的每个元素分配一个分数来排序。 假设可能的分数范围是 0-100。为了获得该分数,我们将使用 2 个比较数据点,一个权重为 75,一个权重为 25。我们称它们为 valu
关闭。这个问题需要更多focused .它目前不接受答案。 想改进这个问题吗? 更新问题,使其只关注一个问题 editing this post . 关闭 4 年前。 Improve this qu
做一排星星作为评级是微不足道的,但我不确定做随机数的正确 flutter 方法是什么? 换句话说,假设我的评分最多为 5 颗星,我该怎么做,只有一颗或两颗星?我可以有一个 switch 语句,并返回带
我需要创建一个灵活的(最好是动态的)评分引擎,就像信用评分或保费计算系统一样。有创建评分引擎实践经验的人有任何建议、示例或建议模式吗? 我已经知道: Rete Algorithm FICO The o
我的索引中有以下类型的文档,但由于深度嵌套方面,找不到正确排序的方法。 文档示例: { "metadatas": [{ "name": "name", "timeValidity"
我正在寻找 Lucene (Java) 中的相似性模块,它给出基于权重的分数。我知道这很模糊,最好用一个例子来解释。 Document 1 ----------- Firstname: Frances
我对 Lucene 8 比较陌生,想了解如何将旧版 Solr 4 评分迁移到 Lucene。这就是 Solr 4 目前的做法。 /* * From the SolrRelevan
我正在使用 Lucene 来构建标记共现的大型索引(例如 [elephant,animal]、[melon,fruit]、[宝马,汽车],...)。我使用 BooleanQuery 查询索引以获取绝对
Ratingbar 星未正确显示。我不知道我做错了什么。当我使用自定义样式时,只显示一颗星,它的长度等于 5 星。 风格是: @drawable/manual_ratingbar
我编写了一个程序,它读取 imdb 上排名前 250 的电影的名称和评分,并返回评分的平均值。我有以下程序 import java.io.IOException; import org.jsoup.*
我有一个直截了当的问题,我将 ngram 用于部分匹配。实现效果很好,但得分结果并不像我希望的那样有效。我希望我的分数结果看起来像这样: 柯:.1 Kev:.2 凯维:.3 凯文:.4 相反,我得到以
假设我有一个像这样的 MySQL 表: 软件表: id int name text votes int rating int 其中投票是某人为该项目投票的次数,评分是这些投票的平均值。 示例数据: i
我在索引期间使用过滤器 EdgeNGramTokenFilter。 当我寻找一个词时。当 Lucene 找到完整单词或另一个单词的一部分时,它的评分不会产生差异。 例如,如果我正在查找单词 PUB。我
我们正在使用 java 并使用 elasticsearch java api 开发一个应用程序。我们对元数据建立了索引,并希望在索引时或搜索时使用排名/评分。 而且,我不知道是否可以对用户单击结果时选
有人可以解释(或引用引用资料)用更简单的词来比较 SOLR 和 LUCENE 使用的评分机制。 它们有什么区别吗? 我不太擅长 solr/lucene,但我的发现表明它们似乎不同。 P.S:我只是尝试
我是一名优秀的程序员,十分优秀!