[英]Loading another page into DIV
Function .load doesn't work on Chrome on localhost (with Xampp). 函数.load在localhost(使用Xampp)上的Chrome上不起作用。
On JsFiddle nothing happens if I run the button. 如果我运行按钮,在JsFiddle上什么也不会发生。 My goal is on load to DIV id="lista_ogol" another page.
我的目标是在另一页上加载DIV id =“ lista_ogol”。 Is it possible?
可能吗?
Thanks for every help, if my code is messy let me know what to change. 感谢您提供的所有帮助,如果我的代码混乱,请告诉我要更改的内容。
Here is my html code: 这是我的html代码:
<ul>
<div id="lista_ogol" class="lista">
<li><a id="rejestracjaID" href="javascript:void(0)" >Rejestracja</a></li>
<li><a href="logowanie.php">Logowanie</a></li>
</div>
</ul>
Here is my Js script: 这是我的Js脚本:
jQuery(function(){
jQuery('#rejestracjaID').click(function(){
jQuery('#lista_ogol').load('logowanie.php',
function(){alert('Content Successfully Loaded.')}
);
});
})
You need to include jquery script in your html file. 您需要在HTML文件中包含jquery脚本。
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
Make sure you put this in the <head>
of your document, or above the script you use to load the PHP page. 确保将其放在文档的
<head>
中,或放在用于加载PHP页面的脚本的上方。
If you aren't getting any jQuery related errors (like $ is not defined
/ jQuery is not defined
), it means jQuery is working fine. 如果您没有遇到任何与jQuery相关的错误(例如,
$ is not defined
/ $ is not defined
jQuery is not defined
),则表明jQuery正常运行。
The first thing that comes into mind ending up in situations like this is that the requested page was not found . 在这种情况下想到的第一件事是找不到请求的页面 。 Try including the correct URL to the
logowanie.php
(eg "/gate/login/logowanie.php"
) as the .load()
might not have been able to locate the file that you have requested. 尝试将正确的 URL包含到
logowanie.php
(例如"/gate/login/logowanie.php"
),因为"/gate/login/logowanie.php"
.load()
可能无法找到您所请求的文件。
Meanwhile, if you want to add any new html page into the DIV, an alternative ( which may or may not serve your purpose ) is to first echo out an iframe and then append it using .append()
method of jQuery as such: 同时,如果您要将任何新的html页面添加到DIV中,另一种选择( 可能会或可能不会达到您的目的 )是首先回显iframe ,然后使用jQuery的
.append()
方法将其附加如下:
jQuery('#lista_ogol').append(<the iframe>);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.