duanmie9741 2011-11-01 10:16
浏览 60
已采纳

如何使用jquery ajax api加载包含大量图像和文本的php页面?

While requesting a php page from the server using .load() api, or for that matter the .ajax() api of jquery, should the php page be a complete one with all the tags and markings, and also the should it have the database connection details in it?

I tried linking the php page using .load() but it does not seem to work. My php page that is being requested would have lots of images and stuff in it. How do I have this php page displayed using the load() api?

thanks.

  • 写回答

2条回答 默认 最新

  • dtr53557 2011-11-01 10:19
    关注

    I believe that the best practice is to load the resource you want to update dynamically,i.e. only load a partial page.

    When loading full pages, it's likely that you're loading a lot of data that you don't need.

    Instead, I'd make a block with the html/images/script that you want to update dynamically, and just load this.

    Example

    Main page

    <html>
      <body>
        <h1>About me</h1>
        <p>Some data about me</p>
        <div class="latest-photos">&nbsp;</div>
      </body>
    </html>
    

    Gallery resource - gallery.block.php

    <ul>
      <li>
        <img src="myphoto1.jpg">
      </li>
      <li>
        <img src="myphoto2.jpg">
      </li>
    </ul>
    

    Script

    jQuery(function($){
      $(".latest-photos").load("gallery.block.php");
    });
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作