Search code examples
jquerypinterest

JQuery doesn't work when I load contents using AJAX


I have a problem when I load page using AJAX.I have created a pinterest type arrangement using jquery.

But when I load it using Ajax it doesn't work.

I have searched for it and found bind() function.But how to use it with .css in JQuery.Results i found after searching weren't satisfactory.


Solution

  • Please change your function like

       function indmoreclik(a,b)
       {
       if (window.XMLHttpRequest)
        {// code for IE7+, Firefox, Chrome, Opera, Safari
        xmlhttp=new XMLHttpRequest();
        }
      else
      {// code for IE6, IE5
      xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
      }
     xmlhttp.onreadystatechange=function()
     {
     if (xmlhttp.readyState==4 && xmlhttp.status==200)
     {
      document.getElementById("more").innerHTML=xmlhttp.responseText;
    
        var t1=0;
        var t2=0;
        var t3=0;
    
      for(j=1;j<=20;j++)
     {
      $('.div1:nth-child('+j+')').css({ top:''+t1+'px',left:'250px'});
      height=$('.div1:nth-child('+j+')').outerHeight(true);
      t1=t1+height;
      $('.div2:nth-child('+j+')').css({ top:''+t2+'px',left:'520px'});
      height=$('.div2:nth-child('+j+')').outerHeight(true);
      t2=t2+height;
     $('.div3:nth-child('+j+')').css({ top:''+t3+'px',left:'790px'});
     height=$('.div3:nth-child('+j+')').outerHeight(true);
     t3=t3+height;
    
      }
     }
        xmlhttp.open("GET","tap2.php?tun="+a+"&inc="+b,true);
         xmlhttp.send();
    

    }