Native ajax request json error

The

page effect can be displayed normally, but open the console and see that there is an error.

this is an error
clipboard.png

this is the code

function getRooms(pagenum){
    var xmlhttp=null
    if(window.XMLHttpRequest){
        xmlhttp= new XMLHttpRequest()
    }else {
        xmlhttp=new ActiveXObject("Microsof.XMLHTTP")
    }
    
    xmlhttp.onreadystatechange=function(){
        
        var data=JSON.parse(xmlhttp.responseText); 
        
        if(xmlhttp.readyState==4&&xmlhttp.status==200){
            
            var tbody=document.getElementsByTagName("tbody")[0];
            tbody.innerHTML="";
            var list=data.Data;
            var count=data.countpage;
                 
            for(var i=0;i<list.length;iPP){
                
                var num = i + (count - 1) * 10 + 1;
                
                var content="<tr id="+list[i].id+">"+
                "<td>"+num+"</td>"+
                "<td class="mrName">"+list[i].name+"</td>"+
                "<td>"+list[i].state+"</td>"+ 
                "<td>"+list[i].meetcount+"</td>"+ 
                "<td>"+list[i].username+"</td>"+
                "<td>"+list[i].begintime+"</td>"+
                "<td>"+
                    "<button class="deleteInfo"></button>"+
                    "<button class="changeInfo"></button>"+
                "</td>"+
                "</tr>"        
                
                tbody.innerHTML+=content
                        
                
            }
        }
    }
    
    xmlhttp.open("post","/Meet/ListAllMeet.do",true)
    
    xmlhttp.setRequestHeader("content-type", "application/x-www-form-urlencoded")
    
    xmlhttp.send("pagenum="+pagenum)
}
Aug.13,2021

The

error is not in the JSON format expected by the specification .
print your passage

var data=JSON.parse(xmlhttp.responseText);

maybe the problem lies in this sentence.
may also check whether there is a problem with the returned data in the background , which is more likely.
check whether the returned string carries some special symbols, such as / n and similar

.

Hello, landlord! When using JSON.parse () , it is recommended to use try.catch to catch the exception, otherwise an error will occur directly. The error information in the above screenshot is usually parsed because it is not in the normal json format.


put var data=JSON.parse (xmlhttp.responseText); on the first line of if below


response to see if the returned data is really json


at first xmlhttp.responseText equals', JSON.parse ('') will report an error.

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e3c45b-439f9.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e3c45b-439f9.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?