Jquery infinity scroll loops over and over using Mysql/PHP - javascript

I'm trying to implement Jquery infinity scroll found at (http://infiniteajaxscroll.com/) together with my MYSQL and PHP. And it works, sort of.
I found similar example here but my was quite different anyway (http://www.w3bees.com/2013/09/jquery-infinite-scroll-with-php-mysql.html)
The loading more works fine however my results are being looped over and over again.
I mean i display all the results in the first page and when i scroll down at the bottom and infinity scroll fires up then same results are being showed instead of splitting those first results in different pages.
Here is my code, quite long :)
<?php
$page = (int) (!isset($_GET['s'])) ? 1 : $_GET['s'];
// GET ALL THE SHOUTBOX
$sql = "SELECT * FROM shoutbox
ORDER BY id DESC
LIMIT 20";
//prepare the statement
$statement = $dbConn->prepare($sql);
//execute the statement
$statement->execute();
//Count the shouboxes
$number_of_shoutbox = $statement->rowCount();
$number_of_posts_per_page = '10';
$total_pages = $number_of_shoutbox / $number_of_posts_per_page;
?>
<div class="background_spacing"></div> <!-- end of background spacing -->
<div id="header_background">
<div class="shoutbox-background text-center">
<div id="shoutbox">
<!-- SHOUTBOX COMPLETE STARTS -->
<div class="shoutbox_complete">
<div class="shoutbox_left">
<img src="images/girl-shoutbox.jpg">
</div>
<div class="shoutbox_right background-white">
<div class="no-padding padding10">
<span class="font24 font-color-000000">NAPISI SVOJ</span>
<span class="font24 username_male">SHOUTBOX</span>
<textarea class="shoutbox-form no-padding" placeholder="Ostavite i vi jedan shoutbox..."></textarea>
<input type="submit" class="button_standard_pink float-right">
</div>
</div>
</div>
<!-- SHOUTBOX COMPLETE STARTS -->
</div> <!-- end of id="shoutbox -->
</div>
</div> <!-- END OF HEADER_BACKGROUND -->
<div class="margin30"></div><!-- Spacing -->
<div class="shoutbox-total">
<div id="shoutbox">
<div class="shoutbox-counter no-padding padding-10 background-shoutbox-counter">
<div class="font48 text-center"><?php count_shoutbox();?></div>
<div class="text-center">shoutbox has been shouted!</div>
<div class="text-center padding-10"><img src="images/default/default-shoutbox-shout.png"></div>
<div class="text-center font10">INVITE YOUR FRIENDS TO SHOUT!</div>
</div>
</div>
<?
//LOOP THROUGH THE SHOUBOXES
while($show_shoutbox = $statement->fetch(PDO::FETCH_BOTH)) {
?>
<div id="shoutbox">
<!-- SHOUTBOX COMPLETE STARTS -->
<div class="shoutbox_complete_display">
<div class="shoutbox_left">
<img src="images/man-shoutbox.jpg">
</div>
<div class="shoutbox_right-display background-box-light-gray">
<div class="no-padding padding-10">
<div class="font24 username_male" style="line-height:1;"><?php echo strtoupper($show_shoutbox['user_name']);?> <?php echo $show_shoutbox['user_age'];?> GODINE</div>
<span class="font-color-898a8b">IZ <?php echo strtoupper($show_shoutbox['country']);?> - TRAŽI <?php echo strtoupper($show_shoutbox['gender_search']);?> IZMEĐU <?php echo strtoupper($show_shoutbox['age_from']);?> I <?php echo strtoupper($show_shoutbox['age_to']);?> GODINA</span>
<div class="margin15"></div>
<div class="font20"><?php echo $show_shoutbox['text'];?></div>
<div style="margin-top:52px;">
<table cellpadding="0" cellspacing="0" width="100%">
<tr>
<td><div class="font18 font-bold">32,222</div>
<span class="font-color-898a8b">ACHIVEMENTS</span>
</td>
<td><div class="font18 font-bold">32,222</div>
<span class="font-color-898a8b">ACHIVEMENTS</span>
</td><td><div class="font18 font-bold">32,222</div>
<span class="font-color-898a8b">ACHIVEMENTS</span>
</td><td><div class="font18 font-bold">32,222</div>
<span class="font-color-898a8b">ACHIVEMENTS</span>
</td>
</tr>
</table>
</div> <!-- end of margin-top:60 -->
</div> <!-- end of no-padding padding-10 -->
<!-- COMMENT START HERE -->
<?php
// d($detail);
$type='question';
// include('like.php');
include('includes/comment.php');
?>
<!-- COMMENT END HERE -->
</div> <!-- end of shoutbox_right-display -->
</div> <!-- end of shoutbox_complete -->
</div> <!-- end of id="shoutbox -->
<?php } // end of the shoubox loop
?>
</div>
<!--page navigation-->
<div id="nav">
<?php
for ($x = 2; $x <= $total_pages; $x++) {
?>
<a href='welcome.php?p=shoutbox&s=<?php echo $x;?>' <?php if($x=='2') { echo 'class="next"';}?>></a>
<?php } ?>
</div>
<script type="text/javascript" src="js/jquery.infinity.scroll.js"></script>
<script type="text/javascript">
var ias = $.ias({
container: ".shoutbox-total .shoutbox_complete_display",
item: "#shoutbox",
pagination: "#nav",
next: ".next"
});
ias.extension(new IASSpinnerExtension());
ias.extension(new IASTriggerExtension({offset: 3}));
ias.extension(new IASNoneLeftExtension({text: 'There are no more pages left to load.'}));
========================================================================
UPDATE CODE BY STILL GIVING ERRORS NOW IN MYSQL:
Tried #Rob Schmuecker solution but now getting errors in mysql.
Here is my modified code with PDO and with Rob Schmuecker suggestion
// GET ALL THE SHOUTBOX
$sql = "SELECT
shoutbox.shoutbox_id,
shoutbox.text,
shoutbox.date,
shoutbox.time,
shoutbox.approved,
shoutbox.`new`,
shoutbox.user_id,
users.profile_image,
users.user_name,
users.user_age,
users.country,
users.gender_search,
users.age_from,
users.age_to
FROM shoutbox INNER JOIN users ON shoutbox.user_ID = users.id
WHERE users.profile_image = '2'
AND shoutbox.approved = '1'
AND shoutbox.new = '0'
AND shoutbox.user_id != :admin_id
AND (shoutbox.user_id NOT IN (SELECT user_id FROM users_blocked WHERE blocked_id = :user_id))
ORDER BY shoutbox.shoutbox_id DESC
LIMIT :limit_start :limit_row_amount";
//prepare the statement
$statement = $dbConn->prepare($sql);
//execute the statement
$statement->execute(array(
'admin_id' => $admin_id,
'user_id' => $user_id,
'limit_start' => $limit_start,
'limit_row_amount' =>$limit_row_amount
));

You need to implement the page into your SQL query.
Below we define two new variables, one which is the total amount you want to retrieve each time and the next is the amount of rows to skip in each limit query, starting from 0 if $page = 1
$page = (int) (!isset($_GET['s'])) ? 1 : $_GET['s'];
$limit_row_amount = 20;
if($page > 1){
$limit_start = $page * $limit_row_amount;
} else {
$limit_start = 0;
}
// GET ALL THE SHOUTBOX
$sql = "SELECT * FROM shoutbox
ORDER BY id DESC
LIMIT $limit_start, $limit_row_amount";

Related

Reload div in jss, jquery

I have a problem that when I use the loop to loop the elements in the session array it still runs normally, I try to use the code to reload only the shopping cart item, it reloads the cart, but it doesn't run. The PHP loop and my shopping cart are empty, what should I do?
<span id="soluonghang" class="badge badge-primary" style="background: #da251c;">
<?php echo $soluongsanpham; ?>
</span>
<div class="popup" id="giocart">
<div class="row header">
<span>Items</span>
<span>Amount</span>
</div>
<?php
if (isset($_SESSION['cart'])) {
foreach ($_SESSION['cart'] as $key => $value) {
?>
<div class="row items" id="itcart">
<span><?php echo $value['name']; ?></span>
<span><?php echo $a = ($value['dongia'] * $value['num']) - ($value['giam'] / 100 * ($value['dongia'] * $value['num'])) ?>đ</span>
</div>
<?php
}
} else {
}
?>
<div class="row checkout">
<span>Đi đến giỏ hàng ></span>
<span class="checkout-button" onclick="refesf()">Refesh giỏ hàng</span>
</div>
</div>
</span>

Scroll bottom chat in AngularJS

I'm trying to scroll the end of the div when I open the ng-show chat window, but it only works on the second click. I've tried it in many ways but I'm not getting it to make the first click work already.
HTML CHAT:
<div class="chat">
<div class="" ng-show="chatdis">
<div class="chat-header vertical-center clearfix">
<img ng-src="user/pix.php/{{ctrl.idchat}}/f1.jpg" class="imgperfil img-circle" alt="avatar" ng-class="{'online': ctrl.useronline, 'offline': !ctrl.useronline}"/>
<div class="chat-about">
<div class="chat-with">{{ctrl.namechat}}</div>
</div>
<div class="close pull-right" style="opacity: 0.6;" ng-click="ctrl.fecharconversa()">
<i class="fa fa-times" aria-hidden="true" style="display: block;font-size: 16px;position: absolute;top: 6px;right: 8px;color: #797979;"></i>
</div>
</div> <!-- end chat-header -->
<div class="chat-history">
<ul style="margin: 0;padding: 0;">
<li ng-id="message-{{obj.id}}" class="clearfix" ng-repeat="obj in ctrl.mensagens | orderBy:'-'">
<div class="message" ng-class="{'other-message': obj.useridto == <?php echo $USER->id ?>, 'my-message float-right': obj.useridto != <?php echo $USER->id ?>}">
<p ng-bind-html="obj.smallmessage"></p>
<span class="tail-container"></span>
<span class="tail-container highlight"></span>
</div>
<div class="message-data" ng-class="{'align-right': obj.useridto != <?php echo $USER->id ?>}">
<span class="message-data-time" ng-class="{'text-right': obj.useridto != <?php echo $USER->id ?>}" ng-if="obj.useridto != <?php echo $USER->id ?>">
{{obj.firstname}} {{obj.lastname}} - {{obj.timecreated | date:"dd/MM/yyyy HH:mm"}}
</span>
<span class="message-data-time" ng-if="obj.useridto == <?php echo $USER->id ?>">
{{obj.timecreated | date:"dd/MM/yyyy HH:mm"}} - {{obj.firstname}} {{obj.lastname}}
</span>
</div>
</li>
</ul>
</div> <!-- end chat-history -->
<div class="chat-message clearfix">
<textarea name="message-to-send" ng-model="message" id="message-to-send" placeholder ="Escreva sua mensagem" rows="2"></textarea>
<button ng-click="ctrl.inseremensagem(ctrl.idchat, message, ctrl.namechat, ctrl.useronline)">Enviar</button>
</div> <!-- end chat-message -->
</div>
</div> <!-- end chat -->
CONTROLLER FUNCTION:
self.abrirconversa = function(useridfrom, name, useronline){
$rootScope.chatdis = true;
chatservice.conversachat(useridfrom).then(function(d) {
self.mensagens = d;
for(var i = 0; i < self.mensagens.length; i++){
//converte datas em Javascript
if(self.mensagens[i].timecreated != null && self.mensagens[i].timecreated != '12/31/1969 21:00'){
self.mensagens[i].timecreated = new Date(self.mensagens[i].timecreated);
}
}
self.idchat = useridfrom;
self.namechat = name;
self.useronline = useronline;
$('.chat-history').animate({scrollTop: $('.chat-history')[0].scrollHeight}, 0);
}, function(errResponse){
console.error('Error while fetching Currencies');
});
};
The controller function, I call it when I click on a list of people in the side menu. Can someone help me? :D

database query fails randomly, cannot replicate on my machine

edit #1:As you can see below I have multiple $db->query 's and I am wondering if this issue could be cause by too many calls to the database on slower connections? cause the page itself works the database calls just don't go through sometimes. IF this is the issue what would be a good solution for that?
I've been having a really hard time with this one. Some reason the database code only works 2/3rds of the time for customers. I have been unable to find a reason why it would not work for them either.
When some customers use my sight everything works fine up until the final page where the payment gateway sends me a transaction ID and a confirmation on whether or not the payment was successful(1 for yes 0 for no). But for some reason my database line that adds the transaction is not working
$db->query("UPDATE transactions
SET charge_id = '{$trans_id}'
WHERE cart_id = '{$cart_id}'");
$cart_id is from a cookie (issue does not lie with users having cookies blocked.) Now I had previously thought that the issue lied within safari and IE (since customers with issue had these browsers) but after some testing both browsers work on my computer and a friends (just in case). So now I really do not know what the issue could be. Without the transaction ID being set the transaction will not be marked as complete which means it doesn't get registered in an admin panel inventory systems and the quantity of the item does not get updated. The ordered and items are going through and processing So the issue has to be on this page.
Current possible ideas(not sure how to fix either):
Too many db query causing issues for people with slower interenet.
Auto cycle side bar causing an issue (2nd code block)
Code:
<?php require_once 'system/init.php'; include 'includes/head.php'; include 'includes/navigation.php'; include 'includes/headerpartial.php'; include 'includes/leftbar.php'; ?>
<div id="maincontent" class="col-md-8">
<?php
if ($_GET['response_code'] == 1) { $trans_id = $_GET['transaction_id'];
$db->query("UPDATE transactions SET charge_id = '{$trans_id}' WHERE cart_id = '{$cart_id}'");
$db->query("UPDATE cart SET paid = 1 WHERE id = '{$cart_id}'");
$tsql = $db->query("SELECT * FROM transactions WHERE charge_id = '$trans_id' ");
$tran = mysqli_fetch_assoc($tsql);
$domain = '.'.$_SERVER['HTTP_HOST'];
setcookie(CART_COOKIE,'',1,"/",$domain,false);
?> <h1 id="reciept">Thank you for your support!</h1><hr> <p id="reciept"> On behalf of LettuceHeadsFarm <?=$tran['full_name']?> we thank you for your purchase and hope you enjoy it! </p>
<p id="reciept"> You have selected <b>"<?=$tran['pickup-location']?>"</b> as your pickup point. </p>
<table id="nav-button" class="table table-bordered table-auto"> <tbody> <tr> <td>Transaction ID : <?=$tran['charge_id']?></td> </tr> <?php $a = 1; $it = 1; $string = $tran['items']; $itemar = explode(',', $string); $num = 1;
$istr = $tran['inventory'];
$stri = explode(',', $istr);
if ($tran['status'] != "Complete") {
foreach (array_slice($stri, $num) as $inve ){
$exploded = explode('.', $inve);
$itname = $exploded['0'];
$itquan = $exploded['1'];
$db->query("UPDATE products
SET `quantity` = `quantity` - '$itquan'
WHERE title = '$itname'");
$db->query("UPDATE products
SET `Sold` = `Sold` + '$itquan'
WHERE title = '$itname'");
$it++;
}
$compl = "Complete";
$db->query("UPDATE transactions
SET `status` = '$compl'
WHERE charge_id = '$trans_id'");
}
foreach (array_slice($itemar, $num) as $itemr ){
?> <tr> <td><?=$itemr?></td> </tr>
<?php $a++; } ?>
<tr> <td> Total: <?=money($tran['grand_total']);?> </td> </tr> </tbody>
</table> <?php }else { echo "Sorry, an error occurred: ".htmlentities($_GET['response_reason_text']); } ?> </div>
<?php include 'includes/rightbar.php'; include 'includes/footer.php'; ?>
Sidebar Code:
<!-- right side bar-->
<div id="sidebar" class="col-md-2" >
<div class="col-md-12" style="font-size: 75%;">
<ul id="tabs" class="nav nav-pills" role="toolbar">
<li role="presentation">
</li>
<li role="presentation">
</li>
<li role="presentation">
</li>
<li role="presentation">
</li>
</ul>
</div>
<br />
<br />
<div class="tabContent" id="insta">
<div class="contentText" id="aboutContent">
<!-- LightWidget WIDGET --> -info removed instagram widget-
</div>
</div>
<div class="tabContent" id="WHoF">
<div id="whoof">
<?php
$sql = "SELECT * from happening ORDER BY post_date desc limit 3 offset 0;";
$result = $db->query($sql);
?>
<?php while($post = mysqli_fetch_assoc($result)) : ?>
<p><b><?=$post['title'];?></b></p>
<hr>
<p ><?= $post['entry']; ?></p>
<hr>
<?php endwhile; ?>
</div>
</div>
<div class="tabContent" id="veggie">
<div>
<p><a href="veggie.php">
<img border="0" alt="Veggie_crate" src="../images/header/veg.png" style="width: 100%; height: 100%;" >
</a></p>
</div>
</div>
<div class="tabContent" id="social">
<div>
-info removed. facebook widget-
</div>
</div>
<script>
$(document).ready(function () {
var timeInterval, tabCount = 0, currnetIndex = 1;
tabCount = $('ul#tabs').find('li a').length;
var tabContentObj = $('.tabContent');
changeTabIndex();
timeInterval = setInterval(function () { changeTabIndex(); }, 6 * 1000);
function changeTabIndex() {
if (currnetIndex > tabCount) {
currnetIndex = 1;
}
tabContentObj.hide();
$('ul#tabs').find('li.selected').removeClass('active');
$('ul#tabs').find('li.selected').removeClass('selected');
var currentAncorObj = $('ul#tabs').find('li a').eq(currnetIndex - 1);
currentAncorObj.parent().addClass('selected');
currentAncorObj.parent().addClass('active');
$(currentAncorObj.attr('href')).show();
currnetIndex++;
};
$('#tabs li').mouseenter(function () {
clearInterval(timeInterval);
}).mouseleave(function () {
timeInterval = setInterval(function () { changeTabIndex(); }, 4 * 1000);
});
$('#tabs li a').click(function () {
tabContentObj.hide();
$('ul#tabs').find('li.selected').removeClass('active');
$('ul#tabs').find('li.selected').removeClass('selected');
var currentAncorObj = $(this);
currnetIndex = $('ul#tabs').find('li a').index($(this)) + 1;
currentAncorObj.parent().addClass('active');
currentAncorObj.parent().addClass('selected');
$(currentAncorObj.attr('href')).show();
currnetIndex++;
//return false;
});
});
</script>
</div>
Try to generate a log of the user request and see what's going on.
$error_code = uniqid(mt_rand(), true);
file_put_contents(__DIR__ . '/cookie_' . $error_code . '.log', print_r($_REQUEST, 1), FILE_APPEND);
This will let you see what information is being supplied by the user during cart submission in order to troubleshoot. $_REQUEST includes $_GET, $_POST, and $_COOKIE data.
If you haven't already, you should also test for the existence of the $cart_id instead of expecting it to have been submitted with the user's request.
if (!empty($cart_id) && $_GET['response_code'] == 1) {
$trans_id = (int) $_GET['transaction_id'];
...//
}else{
echo "Sorry, an error occurred (Error Code: " . $error_code . "): ".htmlentities($_GET['response_reason_text']);
}

Jquery Children

I am trying to create a nice gallery for an e-commerce. - all the current code is here
The front-end layout I got from here followed the tutorial and it worked like a charm.
Then to add the payment module I decided to add a floating div:
<?php foreach ($tes as $te): ?>
<div id="<?php echo $te['Product']['id'] ?>">
<div class="shop-actions">
<div class="list-group">
<span href="#" class="list-group-item active comprar-menu-button">
<?php echo __('<i class="fa fa-shopping-cart"></i> Carrito de Compras'); ?>
</span>
<span href="#" class="list-group-item comprar-menu">
<h3>Agregar al carrito</h3>
<?php echo $this->Form->create('Product', array('default' => false, 'inputDefaults' => array(
'div' => 'form-group',
'label' => false,
'wrapInput' => false,
'class' => 'form-control'))); ?>
<div class="row">
<div class="col-md-12">
<?php
echo $this->Form->input('cantidad', array(
'options' => array(
50 => "50gr",
100 => "100gr",
150 => "150gr",
200 => "200gr",
250 => "250gr",
500 => "500gr",
1000 => "1kg",
'mayoreo' => "mayoreo",
),
'empty' => '(Seleccionar)',
));
?>
</div>
<div class="col-md-12 mayoreo">
<div class="input-group">
<?php echo $this->Form->input('mayoreo', array('label' => '', 'type'=>'number')); ?>
<span class="input-group-addon">KG</span>
</div>
</div>
<div class="col-md-12 subtotal">
<div id="<?php echo $te['Product']['price']; ?>"><span>$0.00 MXN</span> </div>
</div>
<div class="col-md-12">
</br>
<?php echo $this->Form->submit('Agregar', array('div' => 'form-group','class' => 'btn btn-info col-md-12')); ?>
</div>
</div>
<?php echo $this->Form->end(); ?>
<hr />
<h4>Ademas en tu carrito</h4>
<ul>
<li>Lung Jing <span class="pull-right">200gr</span></li>
<li>Pu Erh <span class="pull-right">1kg</span></li>
<li>Lapsang Su shang <span class="pull-right">10kg</span></li>
</ul>
<span class="pull-right">Subtotal: $2,500.00 MXN</span>
</span>
</div>
</div>
[…]
</div>
<?php endforeach; ?>
<span class="loading"></span>
<span class="icon close-content"><i class="fa fa-times"></i></span>
Then I tried to add some jQuery to make the UX nice and smooth…
function formatCurrency(total) {
var neg = false;
if(total < 0) {
neg = true;
total = Math.abs(total);
}
return (neg ? "-$" : '$') + parseFloat(total, 10).toFixed(2).replace(/(\d)(?=(\d{3})+\.)/g, "$1,").toString();
}
$('.comprar-menu-button').click(function(){
$(this).next().slideToggle(function(){
if ($(this).is(':visible')){
$(this).css('display','inline-block');
}
});
});
$('.cantidad-te').change(function(){
var value, product, precio, cantidadEspecial;
value = $(this).val();
product = $(this).parent().parent();
precio = $(this).parent().parent().next().next().children();
cantidadEspecial =product.next();
if (value === 'mayoreo') {
cantidadEspecial.show();
precio.children().html('especifique cantidad');
}else{
cantidadEspecial.hide();
subtotal = precio.attr('id') * value;
precio.children().html(formatCurrency(subtotal) + ' MXN');
}
});
In theory it works, however it only works for the last element on my teas product.
Expected outcome
When clicking on any element it should:
show the div with the shopping cart
slideToggle should show the form to add product to shopping cart
When selecting an element from dropdown it should:
update with correct price
Current outcome
Only slideToggle() works for last element on my grid.
when changing values on dropdown list it does not make the changes specified.
Additional info
To see a live version of how the 3D grid works visit here (this is not the version am currently working with as I havent pushed the changes)
The code for live version is here
Page Source (HTML Outcome) - here as pointed out by #AlexAtNet
Thank you

Bring a WordPress post dynamically

I've been trying to make this feature work for many days now and it's driving me nuts!
I have a single page theme in WP and in one of them there is a div on the left with a list of the posts in the site and on the right, a div that should display the content of the clicked post.
I found this question and followed up the linked tutorial and was partially successful.
I managed to bring the content dinamically, and all I want is being displayed but it seems the order of the tasks are wrong. Heres how it's acting:
I click on the link.
the current content goes away.
the loading span appears correctely.
the SAME content fades in.
after 1 second or so the current content is replaced with the new content and the address bar does not change at all.
Here's the code I have:
atracoes.js
$(document).ready(function() {
var hash = window.location.hash.substr(1);
var href = $('.controle nav li a').each(function(){
var href = $(this).attr('href');
if(hash==href.substr(0,href)){
var aCarregar = hash+'.html #atr-conteudo';
$('#atr-conteudo').load(aCarregar)
}
});
$('.controle nav li a').click(function() {
var aCarregar = $(this).attr('href')+' #atr-conteudo';
$('#atr-conteudo').hide('fast',carregarConteudo);
$('#carregando').remove();
$('#atracoes').append('<span id="carregando">Carregando...</span>');
$('#carregando').fadeIn('normal');
window.location.hash = $(this).attr('href').substr(0,$(this).attr('href'));
function carregarConteudo () {
$('#atr-conteudo').load(aCarregar,'',mostrarNovoConteudo());
}
function mostrarNovoConteudo () {
$('#atr-conteudo').show('normal',esconderCarregando());
}
function esconderCarregando () {
$('#carregando').fadeOut('normal');
}
return false;
});
});
index.php (the dynamic content part)
<div class="main" id="atracoes">
<div class="controle">
<nav>
<?php
$args = array( 'posts_per_page' => 20);
$myposts = get_posts( $args );
foreach ( $myposts as $post ) : setup_postdata( $post ); ?>
<li>
<?php the_title(); ?>
</li>
<?php endforeach;
wp_reset_postdata();?>
</nav>
</div>
<div id="atr-conteudo">
<?php the_post_thumbnail(); ?>
<div id="atr-texto">
<h2><?php the_title(); ?></h2>
<?php the_content(); ?>
</div>
</div>
</div>
single.php (the part I'm plucking with ajax)
<!-- article -->
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<!-- post thumbnail -->
<?php if ( has_post_thumbnail()) : // Check if Thumbnail exists ?>
<a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>">
<?php the_post_thumbnail(); // Fullsize image for the single post ?>
</a>
<?php endif; ?>
<!-- /post thumbnail -->
<div id="atr-texto">
<!-- post title -->
<h1>
<?php the_title(); ?>
</h1>
<!-- /post title -->
<?php the_content(); // Dynamic Content ?>
<?php edit_post_link(); // Always handy to have Edit Post Links available ?>
</div>
</article>
You're calling the functions before you pass them to jQuery to execute, instead of allowing jQuery to execute them:
function carregarConteudo () {
$('#atr-conteudo').load(aCarregar,'',mostrarNovoConteudo);
}
function mostrarNovoConteudo () {
$('#atr-conteudo').show('normal',esconderCarregando);
}
(Notice they no longer have () after the function names)

Categories

Resources