开发者

JQuery .html() failed to work in Chrome

开发者 https://www.devze.com 2023-02-28 23:49 出处:网络
I tried to load test.html in Chrome but saw nothing. But in Firefox, I was able to see the work \"haha\". It looks like the JQuery .html() doesn\'t work in Chrome. I need a remedy. Thanks.

I tried to load test.html in Chrome but saw nothing. But in Firefox, I was able to see the work "haha". It looks like the JQuery .html() doesn't work in Chrome. I need a remedy. Thanks.

test.html:

<html>
  <head>
    <script type="text/javascript" src="../scripts/jquery-1.4.js"></script>
    <script type="text/javascript">
      $(function() {
        $.get(
          'contents.html',
          function(data){
            $('#samplep').html(data);
          });
      });
    </script开发者_如何学JAVA>
  </head>

  <body>
  <div id="samplep">
  </div>
  </body>
</html>

contents.html:

<b>haha</b>


If you are on your computer google chrome disallows access to your computers files. It a security measure and although annoying is probably the right decision.

There is no bug in JQuery, google chrome is just blocking access.

You could probably right a work around that embeds it in an iframe, but it is not worth the time and effort.

I advise downloading xammp or apache so you can access you own computer by http://localhost.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号