使用jQuery导入HTML文件 [英] Import HTML file using jQuery

查看:87
本文介绍了使用jQuery导入HTML文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图用jQuery导入HTML文件:

  $('#section1')。load(' section1.html'); 

问题在于,当代码加载时,jQuery无法正常工作。在这个HTML里面我有一些jQuery UI和一些复选框,如果我不使用加载函数工作,但是如果我导入它,它们不会被识别。

解决方案

最后,我想出了如何解决这个问题。
我尝试使用PHP来代替Jquery加载函数来包含另一个HTML文件。



我使用PHP扩展名重命名了我的文件,并将其上载到虚拟服务器,如MAMP或$ XAMP)。



然后用这个sintax导入我的代码。

 <?php include(your_file_path / your_file_name.html); ?> 

我在主页中包含了一个网站的大部分内容,而其他HTML文件位于同一个文件夹中的主页。我用

 <?php include(section6.html); ?> 

使用此方法后,我的所有Jquery库都能正常工作。


I'm trying to import an HTML file using jQuery:

$('#section1').load('section1.html');

The problem is that when the code is loaded jQuery doesn't work well. Inside this HTML I have some jQuery UI and some checkbox that if I don't use "load" function work, but if I import it, they are not recognized.

解决方案

Finally I figured out how to solve this problem. I tried to include the other HTML file using PHP instead of Jquery load function.

I renamed my file with PHP extension and uploaded it on virtual server like MAMP or XAMP).

Then used this sintax to import my code.

<?php  include("your_file_path/your_file_name.html");  ?>

I included a big section of a website inside the mainpage and my other HTML file was in the same folder of the HOMEPAGE. I used

<?php  include("section6.html");  ?>

After use this method all my Jquery library worked correctly.

这篇关于使用jQuery导入HTML文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆