Last active
July 2, 2021 18:58
-
-
Save AndrewHD/f3e19980565c56b8714739a08c4b67a7 to your computer and use it in GitHub Desktop.
NehgsAjaxController rewrite
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div id="dynamic-content"> | |
</div> | |
<script> | |
const dbDomain = 'https://www.americanancestors.org'; | |
const dbPath = '/exploredatabases'; | |
const pagePath = window.location.pathname.split('/'); | |
let params = new URLSearchParams(window.location.search); | |
if (pagePath[1] === 'search') { | |
if (pagePath[2].includes('database')) { | |
params.set('databaseId', pagePath[3]); | |
params.set('databaseName', pagePath[4]); | |
} | |
if (pagePath[2].includes('category')) { | |
params.set('categoryId', pagePath[3]); | |
params.set('categoryName', pagePath[4]); | |
} | |
} | |
fetch(`${dbDomain}${dbPath}?${params.toString()}`, { | |
credentials: 'include', | |
cache: 'no-cache' | |
}).then(response => { | |
return response.text().then(text => { | |
const node = document.getElementById('dynamic-content'); | |
node.innerHTML = text; | |
}); | |
}); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment