* fix occasional review display issues

This commit is contained in:
Reinhard Pointner 2013-08-13 04:45:11 +00:00
parent 0341ba3608
commit e4fdcb1884
1 changed files with 13 additions and 11 deletions

View File

@ -192,18 +192,20 @@
</div> </div>
<div> <div>
<script type="text/javascript"> <script type="text/javascript">
$.ajax({ $(document).ready(function () {
url: 'reviews.json', $.ajax({
dataType: 'json', url: 'reviews.json',
success: function(data) { dataType: 'json',
var review = data[Math.floor(Math.random() * data.length)] success: function(data) {
if (review.user.length > 0 && review.date.length > 0 && review.text.length > 0) { var review = data[Math.floor(Math.random() * data.length)]
$('#review .user').text(review.user) if (review.user.length > 0 && review.date.length > 0 && review.text.length > 0) {
$('#review .date').text(review.date) $('#review .user').text(review.user)
$('#review .text').text(review.text) $('#review .date').text(review.date)
$('#review').show() $('#review .text').text(review.text)
$('#review').show()
}
} }
} });
}); });
</script> </script>
<p class="head">Posted by <span class="user"></span> on <span class="date"></span></p> <p class="head">Posted by <span class="user"></span> on <span class="date"></span></p>