Click here to Skip to main content
15,353,676 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi all, I am new to coding, so for this problem, I am using AJAX to load contents to my web page, I selected the right element and appended as required but they don't appear on the page. What could be wrong.

<!DOCTYPE html>

    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edgev">
    <link rel="stylesheet" href="index.css">
    <script src="" crossorigin="anonymous"></script>

    <section class="list">
        <header id="header">
            <h1 id="my-name">Erick O Odero</h1>
            <img src="" alt="Author's profile picture" width="60"
            <nav class="main-menu">
                    <li><a href="../intro-to-programming-asteroid/index.html">Home</a></li>
                    <li><a href="#about">About</a></li>
                    <li><a href="#projects">Projects</a></li>
                    <li><a href="#connect">Connect</a></li>


        <section id="about">
            <p> I am healthcare worker in the field of clinical research residing in Memphis Tennessee and now an
                Software Developer. I am currently a student with Code The Dream taking Javascript, HTML, AJAX and <br>
                lessons. When I learnt of the immense potential that technology has to improve health outcomes<br> of
                communities, my interest in coding was conjured and I hope to immerse myself full time in the industry.

        <section class="list">
            <ul id="exp">
                <li>clinical Research Associate - United States</li>
                <li>HIV program coordinator - Kenya</li>
                <li>Health program coordinator - Kenya</li>
                <li>Health Worker Training and Capacity building(volunteer) - Vanuatu</li>

        <section id="projects">



        <section class="list">
            <h1>My tools</h1>
            <ul class="tools">
                <li><a href="">Visual Studio Code</a></li>
                <li><a href="">Windows 10</a></li>
                <li><a href="">Slack</a></li>
                <li><a href="">Freecodecamp</a></li>
                <li><a href="">Whimsical</a>
                <li><a href="">github</a></li>
<section class="section">
            <h1>My resume</h1>
                    <li><a href="#">resume</a></li>

        <section id="skills">
            <h2 class="list">Skills</h2>
            <ul id="skillz"></ul>

        <section id="projects">



    <!--Create leave message section and add form-->
    <section class="section">
        <h2>Leave a Message</h2>
        <form name="leave_message">

            <fieldset id="details">
                <legend>1 Your details</legend>
                <label for="name">Name:</label><br>
                <input type="text" name="name" required="true"><br>

                <label for="email">Email:</label><br>
                <input type="email" name="email" required="true"><br>

            <fieldset id="text_message">
                <legend>2 Your Message</legend>
                <label for="message">Message:</label><br>
                <textarea id="textMessage" name="message" required="true"></textarea><br>

            <button id="submit" class="btn" type="submit">Submit</button>


    <!-- Add message list section-->
    <section id="messages">


    <script src="index.js"></script>



const today = new Date();
const thisYear = today.getFullYear()
const footer = document.querySelector('footer');
const copyright = document.createElement('p');
copyright.innerHTML = `<span> © Erick Odero ${thisYear}</span> `;

let skills = ['html', 'CSS', 'JavaScript'];
const skillsSection = document.getElementById('skills');
const skillsList = document.getElementById('skills').children[1];

for (let i = 0; i < skills.length; i++) {
    const skill = document.createElement('li');
    skill.textContent = skills[i];

// Create and handle edit button
const editMessage = document.querySelector('#text_message');
const editButton = document.createElement('button');
editButton.innerText = 'Edit';
editButton.type = 'button';

editMessage.addEventListener('click', (e) => {
    const button =;
    const span = document.createElement('span');
    const editedMessage = document.createElement('input');
    input.type = 'text';

// Handle message form submit  button
const messageForm = document.querySelector('form[name="leave_message"]')

messageForm.addEventListener('submit', (e) => {
    // prevent default refreshing behavior

    // create variables for each form field
    // const user_name =;
    // const user_email =;
    // const user_message = messageForm.message.value;

    const user_name =;
    const user_email =;
    const user_message =;

    // Display messages in list
    const messageSection = document.getElementById('messages');
    const messageList = messageSection.children[1];
    const newMessage = document.createElement('li');
    newMessage.innerHTML = `<a href="mailto:${user_email.value}">${user_name.value}</a><span> wrote: ${user_message.value}</span>`;

    // create button element
    const removeButton = document.createElement('button');
    removeButton.innerText = 'remove';
    removeButton.type = 'button';

    // handle the removeButton
    removeButton.addEventListener('click', (e) => {
        const entry =;
    // reset the form

const header = document.getElementById('header');

var gitHubRequest = new XMLHttpRequest();
gitHubRequest.onreadystatechange = function () {
    if (gitHubRequest.readyState === 4 && gitHubRequest.status ===200) {
};'GET', '');

gitHubRequest.addEventListener('load', (event) => {
    let repositories = JSON.parse(gitHubRequest.response);

    const projectSection = document.getElementById('projects');
    const projectList = projectSection.lastElementChild;

    for (let i = 0; i < projectList.length; i++) {
        const project = document.createElement('li');
        project.innerText += project[i];

What I have tried:

    by child nodes but all in vain
Updated 7-May-22 7:12am

1 solution

Hello erick odero !

the "constant" keyword prohibites an update of a var ( forbiden re-allocation ).

try with the common "var" as declaration statement.
"var" make the data mutable and so global ( in Js, for all JS scope and calls ).

the "over use" of "constant" blocks you.

vars in JS :
--old features , but good !
var data; -> global / mutable in all scope
data; -> local for scope / mutable

--modern JS :
let data; -> local for scope, inherited from 'lambda expression' (e)=> , but works every where
const data; -> local for scope ( or global if in main scope ) , but "static/fixed" allocation. unmutable, risky.

about the console for trace :
console.log(myData); for simple var.
console.table(myCompositeElement); for array or complex var. try it ;)

some ";" to end instructions are missing.
look at debug section in your web browser to catch syntax leaks or inoperants instructions.
you can plant "console.log(.......);" for lot of var, to be sure your script runs the way you want. ( tracing ).

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900