0 votes
in Programming by (580 points)

This is my js in this inside s is semester1 but if I write data.s it's not working like data.semester1 giving undefined js:

function mcaBooks(s) {
const xhr = new XMLHttpRequest();
xhr.open('GET', '../json//bookmca.json', true);
xhr.onload = function (s) {
    let data = JSON.parse(this.response);

    console.log(data.s);// giving undifined
}
xhr.send();

}

HTML:

<li><b><a id="semester1" onclick="mcaBooks(this.id)">Semester 1</a></b></li>

JSON data:

{
"semester1": [
    "Information technology",
    "Methamatical foundation of CS",
    "Programming and problem solving in c",
    "computer organization abs assembly language programming",
    "Communication skills"
],
"semester2": [
    "Operation System",
    "Database Management System",
    "Data Structure",
    "Computer Oriented Numerical & statistical Methods",
    "Accounts & Management Control"
]

}

Please log in or register to answer this question.

...