Uncaught TypeError: Cannot read property 'appendChild' of null

后端 未结 10 2055
予麋鹿
予麋鹿 2020-12-14 08:43

I\'m getting the following error

Uncaught TypeError: Cannot read property \'appendChild\' of null

myRequest.onreadystatechange @ script.js

10条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-14 08:52

    There isn't an element on your page with the id "mainContent" when your callback is being executed.

    In the line:

    document.getElementById("mainContent").appendChild(p);
    

    the section document.getElementById("mainContent") is returning null

提交回复
热议问题