weixin_33711641 2011-10-25 21:34 采纳率: 0%
浏览 90

jQuery .load 304未修改

Okay, I am loading a div from one page to my current page with the .load function:

<code>
         $(document).ready(function(){ 
         var myUrl = "test.php"
      $("#tags-load").load(myUrl + " #tags");
      $("#share-load").load(myUrl + " .shareinload");
      $("#comments-load").load(myUrl + " #comments");     
         }); 
</code>

Here is my problem, the above method doesn't work in IE 8 and lower, but does work in IE9 and Chrome and Firefox.

I did a bit of messing around and found that the above code can work in IE8 BUT only if I am not calling any images from the test.php (neither img tag images nor background images). Then I checked the HTTP codes to see if I was getting an error there, it turns out I was getting a 304 error when ever an image was being loaded. This led me to believe that IE8 must be having some kind of hangup while caching the images. So I altered my code to turn off caching for jquery requests:

<code>
$.ajax({
  cache: false
  });
     $(document).ready(function(){ 
     var myUrl = "test.php"
  $("#tags-load").load(myUrl + " #tags");
  $("#share-load").load(myUrl + " .shareinload");
  $("#comments-load").load(myUrl + " #comments");     
     });
</code>

Despite altering the code, I am still getting 304 errors. I'm pretty new to Jquery and I'm stuck here, if anyone could help me find a solution to this it would be greatly appreciated,

thanks

  • 写回答

1条回答 默认 最新

  • csdnceshi62 2011-10-26 06:06
    关注

    No reason to make 3 page requests, if its the same page.

    Could you try this:

    var myUrl = "test.php";
    $.ajax({
      url: myUrl,
      cache: false,
      success: function(html){
        var tags = $('#tags',html).html();
        var shareinload = $('.shareinload',html).html();
        var comments = $('#comments',html).html();
        $("#tags-load").html(tags);
        $("#share-load").html(shareinload);
        $("#comments-load").html(comments);
      }
    });
    
    评论

报告相同问题?

悬赏问题

  • ¥15 fesafe材料库问题
  • ¥35 beats蓝牙耳机怎么查看日志
  • ¥15 Fluent齿轮搅油
  • ¥15 八爪鱼爬数据为什么自己停了
  • ¥15 交替优化波束形成和ris反射角使保密速率最大化
  • ¥15 树莓派与pix飞控通信
  • ¥15 自动转发微信群信息到另外一个微信群
  • ¥15 outlook无法配置成功
  • ¥30 这是哪个作者做的宝宝起名网站
  • ¥60 版本过低apk如何修改可以兼容新的安卓系统