簡體   English   中英

當div使用show()顯示時顯示一種方法

[英]Display a method when div is displaying using show()

我已經創建了這樣的html代碼。 單擊鏈接#Loading_Page7后顯示div#Loading_Page8時,我需要在ABC.js中調用一個函數。 它具有Ajax函數,可在PQR.php中運行查詢。 在這里,我給出了我的html頁面的示例。 .js文件以及.php文件

<html>
  <title></title>
  <head>
    <script>
      $(document).ready(function () {
        $("#Loading_Page8").hide();

        $("#EditForms").click(function () {
          $("#Loading_Page7").hide();
          $("#Loading_Page8").show();
            return false;
          });     
        });
      </script>
    </head>

    <body>   
      <div id="Loading_Page7">
        <div id="EditForms" class="AddUser">
          <a href=""><span>Edit/Delete Forms</span>
        </div>      
      </div>
      <div id="Loading_Page8">
        <label>Display Data</label>
        <div id="DisplayFormDetails" style="position: absolute; top:240px; width:1000px;"></div>
      </div>
    </body>
</html>

ABC.js文件

 function ABC {
     $.ajax({ //create an ajax request to load_page.php
         type: "GET",
         url: "UpdateData.php",
         dataType: "html", //expect html to be returned                
         success: function (response) {
             $("#DisplayFormDetails").html(response);
             //alert(response);
         }
     });
 }

最后是.php文件

<?php
include 'connectionPHP.php';

$result = mysqli_query($con, "SELECT * FROM Form");

echo "<table border='1' >
    <tr>
    <td align=center> <b>Roll No</b></td>
    <td align=center><b>Name</b></td>
    <td align=center><b>Address</b></td>
    <td align=center><b>Stream</b></td></td>
    <td align=center><b>Status</b></td>";

while ($data = mysqli_fetch_row($result)) {
    echo "<tr>";
    echo "<td align=center>$data[0]</td>";
    echo "<td align=center>$data[1]</td>";
    echo "<td align=center>$data[2]</td>";
    echo "<td align=center>$data[3]</td>";
    echo "<td align=center>$data[4]</td>";
    echo "</tr>";
}
echo "</table>";
?>

我的問題是如何執行功能ABC。 #Loading_Page8顯示時,我不知道如何運行ajax函數。 之所以將其放入3個單獨的文件中,是因為我需要歸納它們而不是重新編寫代碼,因為我還有更多的鏈接,例如<div id="EditForms" class="AddUser"><a href=""><span>Edit/Delete Forms</span></div

我的第二個問題是,如果在PQR.php文件中編寫了更多查詢,如何執行特定查詢並將回顯的值發送到ajax函數/

首先,您需要糾正

function ABC{ 

function ABC() {

然后,只需將調用添加到您的函數中:

$("#EditForms").click(function(){
  $("#Loading_Page7").hide();
  $("#Loading_Page8").show();
  ABC();
  return false;
});

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM