打错了节点的id了晕
Uncaught TypeError: Cannot read property 'innerHTML' of null
<script type="text/javascript">
function getmore(){
var p = document.getElementById("result").innerHTML;
alert(p)
var xhr = new XMLHttpRequest();
xhr.open('GET', '{{url_for('api.get_posts')}}',true);
xhr.onreadystatechange = function(){
if(xhr.readyState ==4 && xhr.status == 200){
// alert('success');
document.getElementById("result").innerHTML = xhr.responseText;
var data = JSON.parse(xhr.responseText);
if(data){
console.log(xhr.responseText);
p = "fff";
}
else {
console.log('nothing');
}
}
else{
console.log('ajax error');
}
}
xhr.send();
}
</script>
Uncaught TypeError: Cannot read property 'innerHTML' of null
这就不是 AJAX 的问题了吧