Я пытаюсь включить метод в другой метод, и они находятся в том же классе, но я получаю эту ошибку. Мне нужна помощь по этому Uncaught TypeError: this.showContentList не является функцией в XMLHttpRequest.xhr.onreadystatechange code ниже
class XhrRequest{
constructor(_sendQuery, _mainLinkData){
this.sendQuery = _sendQuery;
this.mainLinkData = _mainLinkData;
};
sendRequest(){
xhr.open("POST", "connection/query.php", true);
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
// send the data-category value in the query
xhr.send(this.sendQuery);
};
showSubMenu(){
this.sendRequest();
xhr.onreadystatechange = function(){
if(this.readyState == 4 && this.status == 200){
// convert result to object
let data = JSON.parse(this.responseText);
const ul = document.createElement('ul');
let outputBody = "";
let i = 0;
for(i in data){
// remove the all the white spaces
let dataSubCat = data[i].subCategory.replace(" ", "");
dataSubCat = dataSubCat.replace("-", "");
let subCategoryNoHyphen = data[i].subCategory.replace("-", " ");
outputBody += ` <li>
<a href="#">${subCategoryNoHyphen}</a>
</li>`;
};
ul.innerHTML = outputBody;
subMenu.append(ul);
subMenu.style.opacity = "1";
this.showContentList();
};
};
};
showContentList(){
const subMenuLinks = **strong text**document.querySelectorAll('.sub-link');
this.sendQuery = "query";
console.log(this.sendQuery);
console.log(subMenuLinks);
};
};