2012-07-02 2 views
1

그래서 저는 8 가지 카테고리의 사진 갤러리를 가지고 있습니다. 각 카테고리에는 400 개 이상의 이미지가 있으며이 하위 카테고리는 AJAX에서 호출합니다. 또한 하위 범주에 페이지 매김 시스템이 있습니다. 현재 나는 쓸모가 8 아약스 전화가, 그래서 나는 그것을 두 개의 arguements 줄 : lap == 0 또는 null 정상적인 페이지를 제공하는 경우 어떤 페이지가 있는지 알려주는 'lap' 그렇지 않으면 old + + page = + lap을 제공합니다. 'Oldal'은 두 번째 논점입니다. 첫 번째 카테고리 선택에서 브라우저가 어떤 php 파일을 여는 지 알려줍니다 (kepek_kat1.php 또는 kepek_kat2 ... kepek_kat8.php). 'Oldal'은 카테고리를 열면 하위 카테고리로 들어가는 데 효과적이지만 페이지 매김은 작동하지 않습니다. 그래서 첫 번째 아규먼트가 매김없이 그것을 페이지를 제공 null입니다8 명의 Ajax가 1을 호출합니다.

<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 --> 

: 다음은 8 caregories의 내 코드입니다.

루프에서, 그것은 현재,이 페이지 컨트롤을 표시하는 페이지가 나열
echo "<div class='lapozo'><a onclick='mutikat($page, '../php/kepek_kat1.php');' href='../html/blog.php#amator?page=$page'>$page</a></div>"; } 

은 $ 페이지입니다 :

여기 내 하위 코드입니다.

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 아약스 호출이 있습니다 :

여기 내 아약스 호출입니다. 도와주세요!

고맙습니다.

답변

1

나는 여기

은 예입니다 ... 당신이 8 아약스 비동기 jQuery's $.when.then(); 기능을 사용하여 통화를로드 할 수 있습니다 알고

<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> 
나는 아직도 jQuery를 배우고
+0

을 통해이 일을하는 방법이 아니다 순수한 자바 스크립트? 아마도 – trisztann

+0

,하지만 그것은 훨씬 더 못 생길 것입니다. jQuery와 올바른 jQuery 호출을 포함하도록 예제를 편집하여 시작합니다. – darkAsPitch

+0

좋아요, 그럼 jQuery로 해보겠습니다. 함수 부분에서 내가 사용하는 아약스 호출을 작성해야합니까? – trisztann

관련 문제