0

我在一个页面上有一系列产品,其中包含一个.small-product类,在每个产品中我都有一个图像及其标题作为指向更大视图的链接。

我想要将较大的视图评级加载到 .small-product 布局中。这是 .small-product 的 html:

<div class="small-product">
<div class="photo"><img src="image/path>"</div>
<div class="lato" id="rating-stars"></div>
<div class="title"><a href="link">Title</a></div>  
<div class="price">£5</div> 
</div>

Ajax 的大视图内容:

<div class="product-large-reviews" itemprop="aggregateRating" itemscope itemtype="http://schema.org/AggregateRating">
<span itemprop="ratingValue" itemscope itemtype="http://schema.org/ratingValue" class="rating">{module_ratingrank,/images/rating}</span>
<span itemprop="reviewCount" class="counter-ratings"></span>
</div>

我的 JS 和一些 Jquery:

$('.small-product').each(function() {
  var ratingContainer = $('#rating-stars');
  var spacing = ('+');
  var smallProductLink = $('.small-product a').attr('href'),
  sourceRatings = smallProductLink + spacing +'.product-large-reviews';
  ratingContainer.load(sourceRatings);

});

现在我尝试和工作但它只适用于 1 个单独的元素是如果我使用.load('/href/path/to/large/view .product-large-reviews');

但我希望每个产品都使用他们的链接从他们的大视图中获取他们自己的信息。

我只收到来自服务器的 404 响应,说它找不到,我猜它找不到,因为网址看起来像它们与要加载的类一起加载,例如www.site.com/path/to/large/ view.product-large-reviews。我尝试了在两者之间留出空间的方法,但它一直返回 404。

一些帮助将不胜感激!

4

0 回答 0