Ajax request? Return to data processing? Empty data?

$.ajax({
    type:"POST",
     dataType: "json",
  url:"url",
  data:adata,
    success:function(data){
        console.log(data);
        var arr=[];
        for(var i in data){
            arr.push(data[i])
        }

        var str="";
        for(j=0;j<arr[2].length;jPP){
              str+="<div class="question1">";
              str+="

"+arr[2][j].question+"

"; str+="<ul>"; str+="<li class="jjjj" value="A">"+arr[2][j].answera+"</li>"; str+="<li class="jjjj" value="B">"+arr[2][j].answerb+"</li>"; str+="<li class="jjjj" value="C">"+arr[2][j].answerc+"</li>"; str+="<li class="jjjj" value="D">"+arr[2][j].answerd+"</li>"; str+="</ul>"; str+="</div>"; } $("-sharpcontainer").html(str);

this is the data I requested and the front-end rendering, but sometimes the data returned by the background is three options, sometimes four options, my current processing method is still four options, but there is a undefind, how to deal with it, ask God for help

clipboard.png

Mar.01,2021

judge whether the next d exists

for(j=0;j<arr[2].length;jPP){
              str+='<div class="question1">';
              str+='

'+arr[2][j].question+'

'; str+='<ul>'; str+='<li class="jjjj" value="A">'+arr[2][j].answera+'</li>'; str+='<li class="jjjj" value="B">'+arr[2][j].answerb+'</li>'; str+='<li class="jjjj" value="C">'+arr[2][j].answerc+'</li>'; if(arr[2][j].answerd){ str+='<li class="jjjj" value="D">'+arr[2][j].answerd+'</li>'; } str+='</ul>'; str+='</div>'; }

if(arr[2][j].answerd != undefined)
str+='<li class="jjjj" value="D">'+arr[2][j].answerd+'</li>';

I think this is because the interface is not handled properly, and the options should be returned in an array!

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-1be80ab-318b3.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-1be80ab-318b3.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?