// =============== search.js ================ // Function to search apartments and room according to conditions on the // search-condition.php page function Search() { try { // Create the url var url = "../JHWK_jstay/API/searchAptRoom.php?"; // Create the HTTP request entity var xmlhttps = {}; if (window.XMLHttpRequest) { xmlhttps = new XMLHttpRequest(); } else { xmlhttps = new ActiveXObject("Microsoft.XMLHTTP"); } // Define the handler xmlhttps.onreadystatechange = function() { if (this.readyState == 4) { if (this.status == 200) { // The request was successful, decode returned the JSON data console.log("request successfull\n" + this.responseText); data = JSON.parse(this.responseText); // Update the displayed result with the received data UpdateResult(data); } else { // The request failed console.log("request failed\n" + this.status); } } } // Send the request console.log("get data sent\n" + url); xmlhttps.open("GET",url); xmlhttps.send(); } catch (err) { console.log("Search : " + err.stack); } } // Function to update the displayed result function UpdateResult(data) { try { } catch (err) { console.log("UpdateResult : " + err.stack); } }