我可以使用文本文件离线加载事件吗

发布于 2024-11-30 12:30:23 字数 226 浏览 3 评论 0原文

我想加载一个我保存为纯文本(文件)的 div。我将此文件与 HTML 页面放在同一根目录中。在我的 HTML 页面上,我尝试使用 Jquery 事件加载来调用此文件,如下所示:

$("#tab2").load("textfile");

它不起作用。是否有必要在服务器上在线执行此操作?我把它保存为文本文件是不是做错了什么?我应该保存为 html,这在代码中会是什么样子?

I want to load a div which I have saved as plain text(file). I have this file in the same root as my HTML page. On my HTML page I'm trying to call this file with Jquery event load, like this:

$("#tab2").load("textfile");

It doesn't work. Is it necessary to do this online, on a server? I'm I doing something wrong saving it as a text file? Should I save as html, how would this look like in the code?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

Load data from the server and place the returned HTML into the matched element.

ref: http://api.jquery.com/load/

是的,它必须位于服务器上

Load data from the server and place the returned HTML into the matched element.

ref: http://api.jquery.com/load/

yes it has to be on the server

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文