如何在不刷新页面的情况下刷新php脚本中的最新数据?

时间:2014-01-20 07:28:45

标签: php jquery

1.这是我重新加载的html代码,但我不知道如何!

<div id="latest">
    <div class="box-heading top-box-text"><div class="box-heading-left"><div class="box-    heading-right">{$lng.general.latest_ads}</div></div></div>
    <div class="box2-bottom-gray"><div class="box-left"><div class="box-right"><div     class="box-bottom-left"><div class="box2-bottom-right">
                <div class="vert-box"> 
        {if $no_latest}
                  <table width="100%" cellpadding="0" cellspacing="0">
                  {section name=loop start=0 loop=$no_latest step=1}
        {capture name=some_content assign=details_url}
        {if $seo_settings.enable_mod_rewrite}{seo->makeDetailsLink p1=`$latest[loop].id` p2=`$latest[loop].title`}{else}{$live_site}/details.php?id={$latest[loop].id}{/if}
        {/capture}
                    <tr> 
                      <td valign="middle" class="last-image"><div class="box-image">
            <a href="{$details_url}"><img class="pic" id="lpic{$latest[loop].id}" onmouseover="this.className='pic_over'" onmouseout="this.className='pic'" src="{$live_site}/{$latest[loop].image}" alt="{if $latest[loop].image_id}{$latest[loop].title}{/if}" /></a>
            {if $latest[loop].rented && $ads_settings.enable_rented}<div class="rented" id="lrented{$latest[loop].id}" style="display: none;"></div>{elseif $latest[loop].sold && $ads_settings.enable_sold}<div class="sold" id="lsold{$latest[loop].id}" style="display: none;"></div>{/if}
            </div></td>
        <td valign="middle">
        {if $data_set=="cars" && ($latest[loop].make || $latest[loop].model)}
        <h3><a href="{$details_url}">{$latest[loop].make} {$latest[loop].model}</a></h3>
        {else}
        <h3><a href="{$details_url}">{$latest[loop].title|truncate:40:"...":false}</a></h3>
        {/if}
        {$latest[loop].location_str}
        {if $ads_settings.enable_price && $latest[loop].price>=0}<div class="price">{$latest[loop].price_curr}</div>{/if}
        <div class="date">{$latest[loop].date_nice}</div>
        </td></tr>
                    {if $smarty.section.loop.index<$no_latest-1}
                    <tr>
                      <td colspan="2"><div class="vert-separator"></div></td>
                    </tr>
                    {/if}
                  {/section}
                  </table>
        {/if}
                </div>
</div></div></div></div></div>

2.这是我的php代码请求并将数据发送到数据库我需要使用这里的东西到html代码,但我不确定。

if($ads_settings['enable_latest']) {
    $max_latest = $ads_settings['no_latest'];
    $latest = $listings->getLatest($max_latest);
    $no_latest = count($latest);
    if($ads_settings['no_latest_on_row']) $width_latest = (100/$ads_settings['no_latest_on_row']); else $width_latest=100;
    if($ads_settings['no_featured_on_row']) $width_featured = (100/$ads_settings['no_featured_on_row']); else $width_featured=100;
    $smarty->assign("no_latest",$no_latest);
    $smarty->assign("width_latest",$width_latest);
    $smarty->assign("width_featured",$width_featured);
    $smarty->assign("latest",$latest);
}

1 个答案:

答案 0 :(得分:0)

使用JQuery .load()函数。 .load()使用从外部文件(PHP或HTML)

显示的数据