[英]I am trying to use jquery load, but that doesn't allow script tags when getting a certain piece of code, what can I do?
I was using jquery load to load html inside a div, but they don't allow script tags to be parsed when selecting a certain id from that file. 我正在使用jquery加载将html中的html加载,但是当从该文件中选择某个id时,它们不允许解析脚本标签。 I need to allow script tags to be parsed without the whole page to be loaded, how can I accomplish this. 我需要允许在不加载整个页面的情况下解析脚本标签,我该如何完成这一工作。 This was my old code: 这是我的旧代码:
$('.link_inner').click(function(e){
e.preventDefault();
var link = $(this).attr('href');
$('#content').fadeOut('slow', function(){
$("#content").load( link + " #inner_main_content", function(){
$('#content').fadeIn('slow');
});
});
As you can see, that will not parse the script tags due to selecting parts of the external page, what is a way to allow script tags be selecting and only a certain div in the external web page 如您所见,由于选择了外部页面的一部分,因此不会解析脚本标记,这是一种允许选择脚本标记并且仅选择外部网页中特定div的方法
I ended up using an ajax request like the following 我最终使用了如下的ajax请求
$('.link_inner').click(function(e){
e.preventDefault();
var link = $(this).attr('href');
$('#content').fadeOut('slow', function(){
$.ajax({
url: link,
success: function(e){
$('#content').html('e');
$('#content').fadeIn('slow');
}
});
});
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.