我已经使用jQuery .load()函数创建了一个模板。在测试时我发现它不会加载任何内容。
这是我的加载代码:
function open() {
history.pushState(null, null, "artiesten.php?u=Chato De Veirman");
$('.content').load('artiest_template.php .content');
}
这是我的模板代码:
<?php include('includes/connect.php') ?>
<span class="content">
<div class="right_col" role="main">
<div class="">
<script>alert("nothing")</script>
<div class="row" id="groot">
<div class="col-md-4 col-sm-2 col-xs-12 profile_details">
</div>
<div class="col-md-4 col-sm-8 col-xs-12 profile_details">
<div class="well profile_view">
<div class="col-sm-12">
<h4 class="brief a-titel"><i>Panda 2.0</i></h4>
<div class="left col-xs-7">
<h2 class="a-naam">Laurent Meersman</h2>
<p><strong>Over: </strong><span class="a-over"> Te weinig tijd / Grafische artiest / Gek </span></p>
<ul class="list-unstyled">
<li><i class="fa fa-user"></i> Kernmerk: <span class="a-kernmerk">Gek</span></li>
<li><i class="fa fa-envelope-o"></i> Email: <span class="a-email"><a href= "mailto:laurent.meersman@oc.be">laurent.meersman@oc.be</a></span></li>
</ul>
</div>
<div class="right col-xs-5 text-center">
<img src="images/Laurent Meersman.jpg" alt="" class="img-circle img-responsive a-foto">
</div>
</div>
<div class="col-xs-12 bottom text-center">
<button type="button" class="btn btn-info btn-xs">
<i class="fa fa-video-camera"> </i> Bekijk meer video's.
</button>
</div>
</div>
</div>
</div>
<div class="row" id="klein">
<div class="col-md-2 col-sm-2 col-xs-12 profile_details">
</div>
<div class="col-md-8 col-sm-8 col-xs-12 profile_details">
<div class="well profile_view">
<div class="col-sm-12">
<h4 class="brief a-titel"><i>Panda</i></h4>
<div class="left col-xs-7">
<h2 class="a-naam">Laurent Meersman</h2>
<p><strong>Over: </strong><span class="a-over"> Te weinig tijd / Grafische artiest / Gek </span></p>
<ul class="list-unstyled">
<li><i class="fa fa-user"></i> Kernmerk: <span class="a-kernmerk">Gek</span></li>
<li><i class="fa fa-envelope-o"></i> Email: <span class="a-email"><a href= "mailto:laurent.meersman@oc.be">laurent.meersman@oc.be</a></span></li>
</ul>
</div>
<div class="right col-xs-5 text-center">
<img src="images/Laurent Meersman.jpg" alt="" class="img-circle img-responsive a-foto">
</div>
</div>
<div class="col-xs-12 bottom text-center">
<button type="button" class="btn btn-info btn-xs">
<i class="fa fa-video-camera"> </i> Bekijk meer video's.
</button>
</div>
</div>
</div>
</div>
<?php
echo '<script>alert("' . $_GET['u'] . ' or nothing")</script>';
if($_GET['u']){
$t = mysqli_real_escape_string($connect,$_GET['u']);
$res = mysqli_query($connect, "SELECT * FROM artiesten WHERE Naam='" . $t . "'");
$i = mysqli_fetch_assoc($res);
echo '
<script src="vendors/jquery/dist/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function () {
$(".a-titel").html("' . $i['Titel'] . '");
$(".a-naam").html("' . $i['Naam'] . '");
$(".a-over").html("' . $i['Over'] . '");
$(".a-kernmerk").html("' . $i['Kernmerk'] . '");
$(".a-email").html("' . $i['Email'] . '");
$(".a-foto").attr("src", "images/' . $i['Naam'] . '.jpg");
history.pushState(null, null, "?u=' . $i['Naam'] . '");
});
</script>';
}
?>
</div>
</div>
</span>
有人可以帮我这个吗? 提前谢谢。
答案 0 :(得分:0)
应该是
function open() {
history.pushState(null, null, "artiesten.php?u=Chato De Veirman");
$('.content').load('artiest_template.php');
}
不是
function open() {
history.pushState(null, null, "artiesten.php?u=Chato De Veirman");
$('.content').load('artiest_template.php .content');
}
答案 1 :(得分:0)
jQuery load()接受三个参数,URL,数据和函数。这些参数必须用昏迷分隔。您的load()后面有一些不属于URL的URL。
更改
$('.content').load('artiest_template.php .content');
到
$('.content').load('artiest_template.php');