dragon8002 2014-02-13 06:45
浏览 104

加载内容并逐个显示php ajax

<script>
    function getfilter(str){
        if (str==""){
            document.getElementById("result").innerHTML="";
            return;
        }

        $.ajax({
            url: "Views/pfolioresult.php?q="+str,
            type: "GET",
            //  data: serializedData,
            success: function ( responseText ) {
                $("#result").html(responseText); 
            }
        });
    }
</script>

This code works correctly. But suppose I have 10,000 data in database. This code show all data at once after loading. How is it possible to show data one by one depending on load time. That means when one item is loaded then show it, and other continuously show.

  • 写回答

3条回答 默认 最新

  • drl2051 2014-02-13 06:51
    关注

    Some idea, on how this could be done:

    function show(skip)
    {
        $.ajax({
            url: "Views/pfolioresult.php?skip=" + skip + "q="+str,
            type: "GET",
        //  data: serializedData,
            success: function ( responseText ) {
        $("#result").html(responseText); 
                skip++;
                show(skip);
            }
        });
    }
    
    show(0);
    

    and your query in php should look like:

    SELECT *
    FROM a
    LIMIT $skip, 1
    
    评论

报告相同问题?

悬赏问题

  • ¥15 python按要求编写程序
  • ¥15 Python输入字符串转化为列表排序具体见图,严格按照输入
  • ¥20 XP系统在重新启动后进不去桌面,一直黑屏。
  • ¥15 opencv图像处理,需要四个处理结果图
  • ¥15 无线移动边缘计算系统中的系统模型
  • ¥15 深度学习中的画图问题
  • ¥15 java报错:使用mybatis plus查询一个只返回一条数据的sql,却报错返回了1000多条
  • ¥15 Python报错怎么解决
  • ¥15 simulink如何调用DLL文件
  • ¥15 关于用pyqt6的项目开发该怎么把前段后端和业务层分离