Projekt

Obecné

Profil

Stáhnout (948 Bajtů) Statistiky
| Větev: | Revize:
1 3b343aea Tomáš Pašek
<!-- 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
10
        // (A2) AJAX - USE HTTP:// NOT FILE://
11
        var xhr = new XMLHttpRequest();
12
        xhr.open("POST", "../controller/TableController.php");
13
        xhr.onload = function(){
14
            let results = document.getElementById("results"),
15
                search = this.response;
16
            results.innerHTML = "";
17
            console.log(search);
18
            let parsedJSON = JSON.parse(search);
19
            console.log(parsedJSON);
20
            if (parsedJSON != null) { for (let s of parsedJSON) {
21
                results.innerHTML += "<div>" + s.id + "</div>";
22
            }}
23
        };
24
        xhr.send(data);
25
        return false;
26
    }
27
</script>
28
29
<form onsubmit="return doSearch()">
30
    <input type="submit" value="Search"/>
31
</form>
32
33
<div id="results"></div>