猿问

如何从弹出模式中的按钮执行php代码?

我正在尝试接受第二个模式中显示的申请表格,该模式在第一个模式之后弹出,并为每个显示的帐户提供一个接受按钮。发生的情况是,当第一个模态显示时,涂药器列表将以模态显示,然后当您按下“信息”按钮(正在运行)时,另一个模态将弹出,其中包含涂药器的信息。然后,第二个模式中有一个接受按钮,在该按钮中不起作用。


我试过调用ajax函数,但它似乎不起作用。该功能似乎无法识别出从模态中按下的按钮。


我有这个PHP作为我的模态


 <?php  

@session_start();

 if(isset($_POST["post_id"]))  

 {  

      $output = '';  

      $connect = mysqli_connect("localhost", "root", "", "adappdb");  

////////////////////////////////////////////////

      /*STATUS CHANGE START*/

      $query = "SELECT * FROM adoption_application WHERE application_id = '".$_POST["post_id"]."'";  

      $result = mysqli_query($connect, $query);  

      $row = mysqli_fetch_array($result);


      if ($row['appli_status']==0){

        $newAStatus = 1;

      }else if ($row['appli_status']==1){

        $newAStatus = 2;

      }else if ($row['appli_status']==2){

        $newAStatus = 3;

      }else if ($row['appli_status']==3){

        $newAStatus = 4;

      }else if ($row['appli_status']==4){

        $newAStatus = 5;

      }


      $query = "UPDATE adoption_application SET appli_status='$newAStatus' WHERE application_id = '".$_POST["post_id"]."'";

      mysqli_query($connect, $query);


      if ($row['appli_status']==0){

        $newAS = "On Process";

      }else if ($row['appli_status']==1){

        $newAS = "Waiting for Initial Interview";

      }else if ($row['appli_status']==2){

        $newAS = "Occular";

      }else if ($row['appli_status']==3){

        $newAS = "Waiting for Approval";

      }else if ($row['appli_status']==4){

        $newAS = "Adopted";

      }


      /*STATUS CHANGE END*/

       $query = "SELECT * FROM adoption_application WHERE application_id = '".$_POST["post_id"]."'";  

      $result = mysqli_query($connect, $query);

////////////////////////////////////////////////

      $output .= '  

      <div class="table-responsive">  

           <table class="table table-bordered"> 

           '; 

  

慕虎7371278
浏览 102回答 1
1回答

长风秋雁

您需要将所有jQuery(甚至VanillaJS)函数包装到一个就绪函数中:<script type="text/javascript">&nbsp; &nbsp; $(document).ready(function() {&nbsp; &nbsp; &nbsp; &nbsp; // all of your JavaScript/jQuery code&nbsp; &nbsp; &nbsp; &nbsp; // for example, the function in question:&nbsp; &nbsp; &nbsp; &nbsp; $(document).on('click', '.accept', function(){&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ...&nbsp; &nbsp; &nbsp; &nbsp; });&nbsp; &nbsp; });</script>我们在这里讨论的一个函数,该.accept函数根本没有被ready函数包装,因此失败了。如果您愿意,可以使用速记版本:<script type="text/javascript">&nbsp; &nbsp; $(function(){&nbsp; &nbsp; &nbsp; &nbsp; // all of your JavaScript/jQuery code here&nbsp; &nbsp; });</script>
随时随地看视频慕课网APP
我要回答