简体   繁体   中英

javascript sending value to php

Wondering if anyone can help me out here.

I have this javascript which is sending id to a php page to retrieve details.

    <script>
         $(document).ready(function() {
             displayListings();

        $("#listTb").on("click", "tr", function() {
            var url = "listingDetail.php?listingid="+this.id;
            alert("directing to : " + url);
            window.open(url);
          });
         });
    </script>

When I click on the tr, I do get a pop up message saying

listingDetail.php?listingid=1

Now on the php, im trying to do this to retrieve the id:

    <body>
      <?php
          $listingid = 0;
          if(!isset($_REQUEST['listingid'])){
              exit;
          }else{
              $listingId = $_REQUEST['listingid'];
          }   
       ?>
    </body>

    <table id="listTb" >
       <tbody>
           <tr>
               <td>....<?php echo htmlentities($listingid); ?>.......</td>
           </tr>
       </tbody>

    </table>

It prints 0 here instead of 1.

Im confused why this isint working. Please help !

$listingid$listingId是不同的变量。

        ^-lower case   ^-upper case 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM