从外部源导入html

JQuery Function import html from external source

本文关键字:html 导入 从外部      更新时间:2023-09-26

我有这个JQuery函数:

function addSomeHTML()
            {
                  $("#mysection").html("<div id='myid'>some content here</div>");
            }

我基本上需要这部分:<div id='myid'>some content here</div>从外部文件读取。

有人能帮忙吗?

谢谢

使用AJAX load()方法

$('#mysection').load('yourfile.html');

当然URL也可以指向PHP脚本等