1 year ago
#349816
TLausie
How can I get data from a website when everything is loaded?
I've created a quiz that creates a link when you press buttons. This link leads to a shop and the number of products available depends on the link. I need to be able to see in my quiz how many products are available. I have this right now:
(function () {
require(["jquery"], function ($) {
$(document).ready(function () {
$(btn).click(function () {
async function makeRequest() {
let response = await fetch('https://myshop.test.nl/shoe.html#' + navi.Link.getLink());
// console.log(response.status)
if (response.status === 200){
console.log('werkt')
$("#ProductNumber").load('https://myshop.test.nl/shoe.html#' + navi.Link.getLink() + " span.number-of-items") // the class of the span in which number of products is displayed on the official site
}
}
makeRequest()
});
})
});
})();
navi.Link.getLink are all the values of my buttons. So when i put this link in the browser there is always another number of products available. The problem is that the number of problems without the getLink is 350 and it checks the number of products when the site is loaded so it always shows 350 in my quiz. I tried doing this by checking whether th http status is 200, but this doesn't work. I do get the console.log, but the numbeer of products is still 350. How can I change this?
javascript
jquery
function
async-await
http-status-codes
0 Answers
Your Answer