在点击按钮阿贾克斯重装DIV内容重装、按钮、内容、阿贾克斯

2023-09-11 01:04:32 作者:时间静止了

我们的想法是:我有一个主DIV与汽车信息内容微型的div分为每两个一排,说我越来越从数据库查询,我想在pressing该按钮,以使该主力重装内容与从数据库的新内容,是可以做到?请指教。

code是这样的:

 < D​​IV CLASS =SearchBlocks>
    < D​​IV CLASS =行>
        < D​​IV CLASS =car_section>信息< / DIV>
        < D​​IV CLASS =car_section>信息< / DIV>
        < D​​IV CLASS =car_section>信息< / DIV>
        < D​​IV CLASS =car_section>信息< / DIV>
        ......

    < / DIV>
    &所述; H2类=load_more>&其中;一的id =more_link的href =#>装载详情< I类=图标custom_arrow>&所述; / I>&所述; / a取代;&所述; / H>
< / DIV>
 

解决方案

 函数重载(URL){
       $获得(URL,功能(数据){// $不用彷徨会在URL中定义的页面的内容,并将**数据返回它**变
            $('#行')追加(数据)。
       }
    }

$('#more_link)。点击(函数(五){
        即preventDefault();
        VAR URL ='http://example.com/somepage.html';
        重装(URL); //这个调用重载函数
});
 

万人猛嘘 曼联92分钟失绝杀,主场拿1分,C罗1球1助都被吹

The idea is: i have a main DIV with content mini divs of cars info divided two per row, that i'm getting with a query from DB, i want when pressing that button to make reload of that main content with new content from the DB, is that possible to do ? please advise.

code looks like this:

<div class="SearchBlocks">
    <div class="row">
        <div class="car_section">INFO</div>
        <div class="car_section">INFO</div>
        <div class="car_section">INFO</div>
        <div class="car_section">INFO</div>
        ......

    </div>
    <h2 class="load_more"><a id="more_link" href="#">Load more <i class="icon-custom_arrow"></i></a></h2>
</div>

解决方案

    function reload(url){
       $.get(url, function(data){      // $.get will get the content of the page defined in url and will return it in **data** variable 
            $('#row').append(data);
       }
    }

$('#more_link').click(function(e){ 
        e.preventDefault();
        var url = 'http://example.com/somepage.html';
        reload(url);  // this calls the reload function
});