Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function getQuery(){
- let parameters = ["artist","name","minattack","maxattack","minhealth","maxhealth","cardClass","rarity"];
- req = new XMLHttpRequest();
- req.responseType = "json";
- req.onreadystatechange = function() {
- if(this.readyState == 4 && this.status == 200){
- updatePage(this.response.info);
- }
- }
- send =`?`;
- parameters.forEach(param =>{
- if(document.getElementById(param).value){
- send+=`${param}=${document.getElementById(param).value}&`;
- }
- });
- send = send.slice(0, -1);
- req.open("POST", "http://localhost:3000/cards" + send);
- //remeber to parse min and max health and shit in the server
- req.send();
- }
- function updatePage(info){
- let results = document.getElementById("results");
- for(let i = 0;i < info.length; i++){
- let atag = document.createElement("a");
- atag.href = "http://localhost:3000/cards/" + info[i]._id;
- atag.innerHTML = info[i].name;
- results.append(atag);
- results.append(document.createElement("br"));
- }
- }
Add Comment
Please, Sign In to add comment