pre - JavaScript
Testing if Search engines will execute JavaScript on page with a X-Robots-Tag: noindex
HTTP header. It does a fetch and records if the api endpoint was hit.
This page has:
document.addEventListener('DOMContentLoaded', function () {
// change the text of the paragraph with id "changeThis"
var paragraph = document.getElementById('changeThis');
paragraph.innerHTML = 'post - JavaScript';
fetch('/cont_api/api.php', {
method: 'POST',
body: JSON.stringify({
'action': 'getX',
}),
headers: {
'Content-Type': 'application/json'
}
}).then(function (response) {
return response.json();
}).then(function (data) {
var container = document.getElementById('fetchContainer');
container.innerText = data.message;
}).catch(function (error) {
console.error('Error:', error);
});
});
Just before the </body>