Javascript JS for loop在Wordpress网站上不起作用,尽管它在本地起作用

Javascript JS for loop在Wordpress网站上不起作用,尽管它在本地起作用,javascript,wordpress,restapi,Javascript,Wordpress,Restapi,各位。我是一个初学者程序员,为我们自己的语言学院建立网站 我正在用WordPress(RESTAPI)中的JavaScript构建一个日程安排应用程序。代码运行正常,直到到达这个循环 试过了,没用了。我尝试过修改PHP/MySQL设置,并为此花费了数小时 live网站位于Cloudways上,我在本地使用飞轮 有什么想法吗?(谢谢) 这是代码的一部分 teacherBlocks.forEach((t)=>{ const blockFragment = new DocumentFr

各位。我是一个初学者程序员,为我们自己的语言学院建立网站

我正在用WordPress(RESTAPI)中的JavaScript构建一个日程安排应用程序。代码运行正常,直到到达这个循环

试过了,没用了。我尝试过修改PHP/MySQL设置,并为此花费了数小时

live网站位于Cloudways上,我在本地使用飞轮

有什么想法吗?(谢谢)

这是代码的一部分

teacherBlocks.forEach((t)=>{

    const blockFragment = new DocumentFragment()

    //block info
    const classID = t.te_schedule_class_ID
    const thePermalink = t.te_schedule_class_permalink
    //Create theBlock
    const theBlock = document.createElement('div')
    theBlock.className = `class-desc outlined__dotted`
    theBlock.setAttribute('data-class-id', classID)
    theBlock.setAttribute('tabindex', 0)

    /************************************************************** */
    /** theBlock attributes */

    //Data attributes
    theBlock.setAttribute('teacher-term-id', t.te_teacher_term_id)
    theBlock.setAttribute('teacher-name', t.te_teacher_in_block)
    theBlock.setAttribute('attendance-type', t.te_schedule_attendance_type)
    theBlock.setAttribute('type-of-class', t.te_schedule_lesson_type)
    theBlock.setAttribute('teacher-color', teachColor)

    /************************************************************** */
    /** theBlock Data preparation */

    //Get day
    const dayInBlockTermID = t.te_schedule_day_term_id
    const dayInBlock = t.te_schedule_day
    //Get time
    const timeInBlock = t.te_schedule_time
    //Ready times for height
    const timeInBlockStr = timeInBlock.replace(/:/g,'').replace('-','')
    const startTime = timeInBlockStr.substr(0,4)
    const endTime = timeInBlockStr.substr(4,4)
    //Block height
    const startTimePx = timeNotation[startTime]
    const endTimePx = timeNotation[endTime]
    const blockHeight = (endTimePx - startTimePx)

    //Block styles
    theBlock.style.position = 'absolute'
    theBlock.style.top = startTimePx + 'px'
    theBlock.style.minHeight = blockHeight + 'px'
    theBlock.style.maxHeight = blockHeight + 'px'
    theBlock.style.width = theBlockWidthPx + 'px'
    theBlock.style.backgroundColor = teachColor

    //block text content
    const highlightText = t.te_schedule_block_highlight_text
    const blockText = t.te_schedule_block_normal_text

    //room_label + room_url
    const roomLabel = t.te_room_label
    const roomURL = t.te_room_url

    /************************************************************** */
    /** theBlock Data preparation: Students */

    //Get students
    const profiles = t.te_st_profiles
    const students = t.te_schedule_students //To replace with PROFILES

    //students Div
    const studentNamesDiv = document.createElement('div')
    studentNamesDiv.className = 'student-names-in-block'    

    //Profiles
    if(profiles){
        const profileFragment = new DocumentFragment()

        profiles.forEach(profile =>{
            //delete the 'students' and leave only 'profiles'
            const oldSt = studentNamesDiv.querySelectorAll('[old="yes"]')
            oldSt.forEach(old => {
                old.classList.add('hidden')
            })

            const profileID = profile.st_profile_id
            const profileName = profile.st_profile_name
            const profileSlug = profile.st_profile_slug
            const profileEmail = profile.st_user_email
            
            const profileLink = document.createElement('a')
            profileLink.className = 'profile-link'
            profileLink.setAttribute('target', '_blank')
            profileLink.setAttribute('data-id', profileID)
            profileLink.setAttribute('data-slug', profileSlug)
            profileLink.setAttribute('data-name', profileName)
            profileLink.setAttribute('href', `${scheduleLocalize.teSiteUrl}/st-student/${profileName}`)

            //const copyBtn = document.createElement('span')
            //copyBtn.className = 'copy-btn dashicons dashicons-paperclip'
            //profileLink.appendChild(copyBtn)

            if(profileEmail === null){
                const errorAsterisk = document.createElement('span')
                errorAsterisk.innerHTML = '*'  
                profileLink.appendChild(errorAsterisk)  
            }

            profileLink.innerHTML += profileName + '</br>'

            
            profileFragment.appendChild(profileLink)

        })
        studentNamesDiv.appendChild(profileFragment)
    }
    
    /************************************************************** */
    /** theBlock innerHTML*/

    theBlock.innerHTML += 
    `<div class="block-text-contents">
            ${highlightText ? `<span class="highlight-text"> ${highlightText} </span>` : ''}
            <span class="block-text">${blockText}</span>
    </div>

    <a class="day-time" day-term-id="${dayInBlockTermID}" day="${dayInBlock}" time="${timeInBlock}" target="_blank" href="${thePermalink}">${dayInBlock + ` ` + timeInBlock}</a>

    <div class="block-buttons">
        ${roomLabel != false
            ? `<a target="_blank" class="room-button" href="${roomURL}">${roomLabel}</a>`
            : ``}<a target="_blank" class="report-button" href="${thePermalink}">Report</a>
    </div>`

    /*************************************************** */
    /** Insert the theBlock in its day > teacher column */
    /** They will be sorted by their class Desc ID */

    blockFragment.appendChild(theBlock)
    teacherDiv.appendChild(blockFragment)
})
teacherBlocks.forEach((t)=>{
const blockFragment=new DocumentFragment()
//块信息
const classID=t.te\U进度表\U类\U ID
恒量permalink=t.te\u进度表\u等级\u永久性
//创建块
const theBlock=document.createElement('div')
block.className=`class desc outline\uu`
setAttribute('data-class-id',classID)
setAttribute('tabindex',0)
/************************************************************** */
/**块属性*/
//数据属性
setAttribute('teacher-term-id',t.te\u teacher\u term\u id)
setAttribute('teacher-name',t.te_teacher_in_block)
block.setAttribute('attention-type',t.te\u schedule\u attention\u type)
setAttribute('type-of-class',t.te\u schedule\u lesson\u type)
setAttribute('teacher-color',teachColor)
/************************************************************** */
/**块数据准备*/
//有一天
const dayInBlockTermID=t.te\u时间表\u日期\u期限\u id
const dayInBlock=t.te_计划_天
//有时间
const timeInBlock=t.te_计划时间
//身高准备时间
常量timeInBlockStr=timeInBlock.replace(/:/g',).replace('-','')
const startTime=timeInBlockStr.substr(0,4)
const endTime=timeInBlockStr.substr(4,4)
//块高
常量startTimePx=时间符号[startTime]
const endTimePx=时间符号[endTime]
常数块高度=(endTimePx-startTimePx)
//块样式
theBlock.style.position='absolute'
theBlock.style.top=startTimePx+'px'
block.style.minHeight=blockHeight+'px'
block.style.maxHeight=blockHeight+'px'
theBlock.style.width=块宽度px+“px”
block.style.backgroundColor=教学颜色
//块文本内容
const highlightText=t.te\u计划块\u突出显示\u文本
const blockText=t.te\U时间表\U块\U正常\U文本
//房间标签+房间url
const roomLabel=t.te_房间标签
const roomURL=t.te_room_url
/************************************************************** */
/**区块数据准备:学生*/
//吸引学生
const profiles=t.te_st_profiles
const students=t.te_schedule_students//替换为配置文件
//学生组
const studentNamesDiv=document.createElement('div')
studentNamesDiv.className='块中的学生名称'
//轮廓
如果(配置文件){
const profileFragment=new DocumentFragment()
profiles.forEach(profile=>{
//删除“学生”并只留下“个人资料”
const oldSt=studentNamesDiv.queryselectoral('[old=“yes”]'))
oldSt.forEach(旧=>{
old.classList.add('hidden')
})
const profileID=profile.st\u profile\u id
const profileName=profile.st\u profile\u name
const profileSlug=profile.st_profile_slug
const profileEmail=profile.st_user_email
const profileLink=document.createElement('a')
profileLink.className='profile link'
profileLink.setAttribute('target','u blank')
profileLink.setAttribute('data-id',profileID)
setAttribute('data-slug',profileSlug)
profileLink.setAttribute('data-name',profileName)
profileLink.setAttribute('href',`${scheduleLocalize.teSiteUrl}/st student/${profileName}`)
//const copyBtn=document.createElement('span'))
//copyBtn.className='复制btn dashicons dashicons回形针'
//profileLink.appendChild(copyBtn)
如果(profileEmail==null){
常量errorAsterisk=document.createElement('span'))
errorAsterisk.innerHTML='*'
profileLink.appendChild(错误星号)
}
profileLink.innerHTML+=profileName+'
' profileFragment.appendChild(profileLink) }) studentNamesDiv.appendChild(profileFragment) } /************************************************************** */ /**块内部HTML*/ theBlock.innerHTML+= ` ${highlightText?`${highlightText}`:''} ${blockText} ${roomLabel!=错误 ? `` : ``} ` /*************************************************** */ /**在其日期>教师列中插入该块*/ /**它们将按其类描述ID进行排序*/ blockFragment.appendChild(块) teacherDiv.appendChild(块碎片) })
Cloudways上的我的服务器:PHP7.4--MySQL 10.1--server Apache/Nginx

我的本地服务器:PHP7.3.5——MySQL 8.0.16——飞轮本地版的服务器Nginx

这个问题不会发生在我的本地环境中,只会发生在Cloudways上

有人知道我在哪里可以找到更多的错误吗

更新2021-04-25: 使用DevTools,我发现同一个变量“d”=在我的live网站上未定义,而在我的本地网站上它等于1。
试图找出原因。

最后!找到了答案

在本地服务器中,我更改了一个ACF字段以返回ID而不是对象。 它现在在json响应中返回: “TEU计划日期限id”:247

在我的live网站上,我没有对f