简体   繁体   中英

I want to retrive data in tabular form using ajax and php

I have written the following code

<!DOCTYPE html>
<html lang="en">
<head>
        <meta charset="UTF-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <meta name="viewport" content="width=device-width, initial-    scale=1.0">
        <title>contact.dat</title>
      <body>
      <div id="demo">
    <h2>Retrive data by ajax</h2>
    <button type="button" onclick="printdata()">Retrive data</button>
    </div>
    
    <script>
    function printdata() {
      const xhttp = new XMLHttpRequest();
      xhttp.onload = function() {
        document.getElementById("demo").innerHTML +=this.responseText;
      }
      xhttp.open("GET", "contact.dat");
      xhttp.send();
    }
    </script>
      </body>
    
    <?php
    
    $fp = fopen('contact.dat', 'r');
    echo "<table border=1>";
    echo "<tr><th>Sr. No.</th><th>Name</th><th>Residence No.</th><th>Mob.
    no.</th><th>Address</th></tr>";
    while ($row = fscanf($fp, "%s %s %s %s %s")) {
        echo "<tr>";
        foreach ($row as $r) {
            echo "<td>$r</td>";
        }
        echo "</tr>";
    }
    echo "</table>";
    fclose($fp);
    ?>
    
    </html>

its showing me这个输出 I want to show data when I click on the button. I'm new in both JavaScript as well as PHP. is there any way to perform something like

if(isset(printdata();))

then run php code block???

Here lies the wrong

/usr/bin/env /opt/jdk17/bin/java .... java.ASG6Ba 

Probably the file that you try to execute is ASG6Ba.java .

The provided file java.ASG6Ba with the ending ASG6Ba makes no sense for java to be executed.

Also java is a prohibited name for packages in java and since the file provided is java.ASG6Ba , java thinks that java is a package name and then follows the class name ASG6Ba . This is the specific reason the error is thrown.

Prohibited package name: java

This is also described in java documentation in chapter 6.1

The first component of a package or module name must not be the identifier java . Package and module names that start with the identifier java are reserved for packages and modules of the Java SE Platform

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