iScroll Ajax内容


                    

我在用ajax加载包装后刷新包装中的内容时遇到问题。</ p>

当我检查Firebug时-XHR显示请求,并且我可以看到已加载的元素,但页面上未显示。</ p>

这就是我使用的pullDown函数来获取Ajax内容</ p>

  function pullDownAction(){
     setTimeout(function(){
         var el,li,i;
         el = document.getElementById('thelist');
         var http = new XMLHttpRequest();
         var url = window.location;
         http.open(“ GET”,url,true);
         http.send();
         myScroll.destroy();
                 myScroll = null;
                 loading();
   },1000);
}
</ code> </ pre>

似乎内容停留在网页上显示和ajax请求之间。</ p>

有什么主意吗?</ p>
     </ div>

展开原文

原文

i have problem with refreshing content in wrapper after it is loaded by ajax.

When i check with firebug - XHR is showing request and i can see elements loaded but it isn't showing on page.

This is what i am using for pullDown function to get ajax content

function pullDownAction () {
    setTimeout(function () {   
        var el, li, i;
        el = document.getElementById('thelist');
        var http = new XMLHttpRequest();
        var url = window.location;
        http.open("GET",url,true);
        http.send();
        myScroll.destroy();
                myScroll = null;
                loaded();
  }, 1000);   
}

It looks like as content is stuck between showing on webpage and ajax request.

Any idea?

1个回答


myScroll.refresh()</ code>(而不是.destroy()并调用“ loaded()”)应该可以解决问题!
如果您使用的是IScroll4,则可以尝试使用iscroll的 checkDOMChanges:true </ code>选项。</ p>

如果它仍然不起作用-可能是CSS问题,由滚动包装器(#scroller)不能随其内容扩展。 ( float </ code>, position:absolute; </ code>或类似的东西)</ p>

编辑:在我看来,因为您根本没有处理请求的responseText! </ p>

根据此示例 onreadystatechange </ code>事件的事件处理程序:</ p>

  http.open(“ GET”,url,true);
  http.onreadystatechange = function(){
        如果(http.readyState == 4){
           alert(http.responseText); //处理这个回应! (即写入元素的innerHTML)
       }
  };
  http.send(null);
</ code> </ pre>
     </ div>

展开原文

原文

myScroll.refresh() (instead of .destroy() and recalling "loaded()") should do the trick! If you're using IScroll4 you can try to use the checkDOMChanges:true option of iscroll.

If it still won't work - it could be a CSS issue caused by the scroll-wrapper (#scroller) not expanding with its content. (float,position:absolute; or something like that)

EDIT: it seems to me as you're not handling a responseText of the request at all!

According to this example you need an event handler for the onreadystatechange event:

 http.open("GET",url,true);
 http.onreadystatechange = function () {
       if (http.readyState == 4) {
          alert(http.responseText); //handle this response! (i.e. writing to an element's innerHTML)
      }
 };
 http.send(null);

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问