Projekt

Obecné

Profil

Stáhnout (947 Bajtů) Statistiky
| Větev: | Revize:
1
<!-- TESTOVACI INDEX-->
2
<?
3
include "../controller/TableController.php"
4
?>
5
<script>
6
    function doSearch () {
7
        // (A1) GET SEARCH TERM
8
        var data = new FormData();
9
        // (A2) AJAX - USE HTTP:// NOT FILE://
10
        var xhr = new XMLHttpRequest();
11
        xhr.open("POST", "../controller/TableController.php");
12
        xhr.onload = function(){
13
            let results = document.getElementById("results"),
14
                search = this.response;
15
            results.innerHTML = "";
16
            console.log(search);
17
            let parsedJSON = JSON.parse(search);
18
            console.log(parsedJSON);
19
            if (parsedJSON != null) { for (let s of parsedJSON) {
20
                results.innerHTML += "<div>" + s.id + "</div>";
21
            }}
22
        };
23
        xhr.send(data);
24
        return false;
25
    }
26
</script>
27

    
28
<form onsubmit="return doSearch()">
29
    <input type="submit" value="Search"/>
30
</form>
31

    
32
<div id="results"></div>
(1-1/8)