1

だから私は8つのカテゴリを持つ写真ギャラリーを持っています. 各カテゴリには 400 以上の画像があり、これらのサブカテゴリは AJAX によって呼び出されます。サブカテゴリにもページネーション システムがあります。現在、私は 8 つの ajax 呼び出しを持っていますが、これは役に立たないので、2 つの引数を指定してそれらを 1 つに縮小したいと思います。それ以外の場合は、oldal+?page= + ラップが返されます。'Oldal' は 2 番目の引数で、最初のカテゴリ選択で使用され、どの php ファイルを開くか (kepek_kat1.php または kepek_kat2 ... kepek_kat8.php) をブラウザーに指示します。「Oldal」は、カテゴリを開いてサブカテゴリに移動するとうまく機能しますが、ページネーションは機能しません。これが私の8つのケアゴリーのコードです:

  <div id="kepek">
    <div class="kepkat"><a href="#amator" onclick="mutikat(null,'../php/kepek_kat1.php');"><img src="../img/kepkat/amator.jpg" height="130px" width="90px" alt="Amatőrök"/><br/>Amatőr</a></div></div> <!-- only showing the first selection -->

したがって、最初の引数は null であり、ページネーションのないページになります。

ここに私のサブカテゴリコードがあります:

echo "<div class='lapozo'><a onclick='mutikat($page, '../php/kepek_kat1.php');'  href='../html/blog.php#amator?page=$page'>$page</a></div>"; }

$page はループ内にあり、現在どのページにあるかを一覧表示し、ページ コントロールを表示します。

これが私のajax呼び出しです:

function mutikat(lap, oldal)
{
            //create XMLHttpRequest object
            xmlHttpRequest = (window.XMLHttpRequest) ? 
            new XMLHttpRequest() : new ActiveXObject("Msxml2.XMLHTTP");

            //If the browser doesn't support Ajax, exit now
            if (xmlHttpRequest == null)
            return;

            if(lap == 0 || lap === 0 || lap == null )
            {
            //Initiate the XMLHttpRequest object
            xmlHttpRequest.open("GET", oldal, true);
            }
            else
            {
                xmlHttpRequest.open("GET", oldal + '?page=' +lap, true);
            }
            //Setup the callback function
            xmlHttpRequest.onreadystatechange = StateChange;

            //Send the Ajax request to the server with the GET data
            xmlHttpRequest.send(null);
}
function StateChange()
{
            if(xmlHttpRequest.readyState == 4)
            {
            document.getElementById('kepek').innerHTML = xmlHttpRequest.responseText;
            }
}

8つのajax呼び出しがあります。私を助けてください!

どうもありがとう!

4

1 に答える 1

1

jQueryの$.when.then();を使用して非同期で8つのajax呼び出しをロードできることを知っています。関数...

次に例を示します。

<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){


    $.when(
        $.getScript("http://domain.com/script_one.js"),
        $.getScript("http://domain.com/script_two.js"),
        $.getScript("http://domain.com/script_three.js"),
        $.getScript("http://domain.com/script_four.js")
    ).then(

        $(function() {

            //work with downloaded scripts and their variables here

        })

    );
});
</script>
于 2012-07-02T20:08:20.843 に答える