[英]jquery .load() , loads a white page
i have a problem with jquery. 我对jquery有问题。 when i use the .load() api it doesn't work. 当我使用.load()api时不起作用。 i use this code: 我使用此代码:
<script type="text/javascript">
$(document).ready(function(){
$(document).ajaxStart(function(){
$("#loading").show();
}).ajaxStop(function(){
$("#loading").hide();
}).ajaxError(function(){
alert("Error on load page!");
});
$("ul li a").on("click", function(){
var twLink = $(this).attr( 'href' );
//i used the event.preventDefault(); too, but it does not work
$("#Container").load( twLink + "#ContainerChild" );
return false;
});
});
</script>
it goes to a white blank page that there are the ads in the page! 转到白色空白页,其中包含广告! but when i use this code in w3 schools try it editor it works perfectly! 但是,当我在W3学校中使用此代码时,请尝试使用它的编辑器!
i have a demo from the problem : http://www.nowsud.rzb.ir and go then click on the "موضوعات"! 我有一个关于该问题的演示: http ://www.nowsud.rzb.ir,然后单击“موضوعات”! (see the pic of this location: http://i.stack.imgur.com/PLPDl.jpg ) lists too see the problem. (请参阅此位置的图片: http : //i.stack.imgur.com/PLPDl.jpg )列表也看到了问题。
well i want to make my blog ajax. 好吧,我想将我的博客设为ajax。
Please try this: 请尝试以下方法:
<script type="text/javascript">
$(document).ready(function(){
$(document).ajaxStart(function(){
$("#loading").show();
}).ajaxStop(function(){
$("#loading").hide();
}).ajaxError(function(){
alert("Error on load page!");
});
$(".tw-content ul li a").click(function (e) {
e.preventDefault();
var twLink = $(this).attr('href');
console.log('Link: ' + twLink);
$("#Container").load(twLink + ' #ContainerChild');
});
});
</script>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.