使用jquery在其他页面中加载一个html页面 [英] loading one html page inside other using jquery

查看:142
本文介绍了使用jquery在其他页面中加载一个html页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在同一位置的
另一个html页面(index.html)中加载一个html文件(hello_world.html)这两个文件。
这是我写的代码。但它没有加载任何东西。
这两个警报正在工作(我故意给予检查
jquery是否正在工作或没有其他用途)
代码中的错误是什么?我不想使用ajax。

 < / head> 
< script type =text / javascriptsrc =../ jquery-1.3.2.js>< / script>
< script type =text / javascript>
$(document)。ready(function(){
alert(ya loaded);
$('#container')。load('hello_world.html');
alert(finished);
});
< / script>
< / head>

< body>
< div id =container>
< / div>

< / body>


解决方案

使用firebug或chrome开发控制台检查可能的错误。

编辑:

当您使用ajax时,有时浏览器不会使用<$ c $加载它c> file:/// 协议。
您应该在本地使用Web服务器(例如windows或apache上的xampp),
并在 http:// 协议中访问您的网站。

这很可能是您问题的原因。


I want to load an html file ("hello_world.html") inside another html page ("index.html") both files in the same location. This is the code I wrote. But It is not loading anything. both alerts are working ( which I intentionally gave to check whether jquery is working or not .no other use with it) what is the error in the code ? I dont want to use ajax.

</head>
 <script type="text/javascript" src="../jquery-1.3.2.js"></script>
    <script type="text/javascript">
        $("document").ready(function() {
        alert("ya loaded");
        $('#container').load('hello_world.html');
    alert("finished");  
  });
</script>
</head>

<body>
<div id="container">
</div>

</body>

解决方案

Use your firebug or chrome development console to check out possible mistakes.

Edit:

When you use ajax, sometimes browser will not load it using file:/// protocol. You should be using a web server locally (such as xampp on windows or just apache), and aproach your website in http:// protocol.

That is very likely cause of your problem.

这篇关于使用jquery在其他页面中加载一个html页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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