February 27, 2013
How to update the data in one region through ajax?
Question by user2046638
i want to upload the data in one region of four links, when I clicked the link1 it will load the data in specific region, and when I clicked the link 2 it will load the page on the same region where first link open, how can I do that?
<div class="container">
<div class="span-5">
<ul>
<li><?php echo $this->Manager->link('Ecommerce',array('controller'=>'associations','action'=>"view_report"),array('id'=> 'home','class'=>'nav'));?></li>
<li><a href="#" id="home" class="nav">Home</a></li>
<li><a href="#" id="about" class="nav">About</a></li>
<li><a href="#" id="contact" class="nav">Contact Us</a></li>
</ul>
</div>
</div>
the data which I want to open from ecommerce link is int the newfile.ctp like that
<?php v_start($this);?>
<h1><?php echo __l('View Report');?></h1>
<div class="firsttable">
<table width="100%" border="0" cellspacing="0" cellpadding="2">
<thead>
<tr class="heading">
<td><?php echo __l('Financials');?></td>
<td><?php echo __l('Payment Methods');?></td>
<td><?php echo __l('By Credit Card');?></td>
</tr>
</thead>
<tbody>
<tr>
<td>
<?php
echo __l("YTD t ");
$ytd_total=0;
foreach ($YTD as $yearData)
{
$ytd_total +=$yearData['AssocPaymentDetail']['membership_fee'] - $yearData['AssociationDiscount']['amount'];
}
echo $ytd_total."<br />";
?>
<?php
echo __l("Last 5days ");
$fda_total= 0;
foreach ($fiveDays as $fiveDaysData)
{
$fda_total += $fiveDaysData['AssocPaymentDetail']['membership_fee'] - $fiveDaysData['AssociationDiscount']['amount'];
}
echo $fda_total ."<br />";
?>
</td>
<td><?php echo __l('creditcard');?> <?php echo __l($ccSum) ?> </td>
<td>
<?php
// debug($paymentRecord);
// debug($ccIndex);
foreach($paymentRecord as $data =>$key){
foreach($ccIndex as $index){
if($data== $index)
{
echo "$data ttt";
if(is_array($key))
echo array_sum($key);
else
echo "tt $key";
}
echo "<br/>";
}
}
?>
</td>
</tr>
</tbody>
</table>
</div>
Please help me to do this, thanks in advance
Answer by Starx
You can attach a single request handler to all links with nav
as class name and then load the output to a container
$(".nav").on('click', function() {
$("#loadingdiv").load("linktoload.php"); // or other
});