JQuery .html() failed to work in Chrome
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.
精彩评论