2017-04-10 19 views
1

jQuery .load()関数を使用してロードしたいテンプレートを作成しました。テストすると、ロードされないことがわかりました。ここで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:[email protected]">[email protected]</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:[email protected]">[email protected]</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

になぜあなたは 'あなたのロード機能でファイルパスを.content'ているのですか? –

+0

@DiddleDotこれは、リフレッシュするのではなく、ロードしたい特定のものだけをロードするためです。 –

+0

load()内のWaarom staat ".content" achteraan? ".content"はURLの上に表示されます。インディペンダリパラメータとロードパラメータは、カンマで区切って入力します。 – Kobbe

答えて

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

あなたは大歓迎です! – JBoy

0

jQueryの負荷であるべき)は、3つのパラメータ、URL、データと機能を取ります。これらのパラメータは、昏睡状態で区切られなければならない。あなたのload()には、URLの背後にURLの一部ではないものがあります。

変更

$('.content').load('artiest_template.php .content'); 

$('.content').load('artiest_template.php'); 
+0

ありがとう、それは働いた。 –

関連する問題