JSON中的第一个对象,没有计数器

时间:2019-06-13 13:09:45

标签: javascript php jquery json ajax

我试图做一个记忆游戏,但是我被卡住了。

我正在尝试将所有匹配项放入这样的JSON文件中:

 this.modalData.columnPermissions.forEach(a => {
  if (allType === 'Write' && !a.IDM) {
    a["can" + allType] = state
  } else if (allType === 'Read') {
    a["can" + allType] = state
  }
 })

问题是系统添加到json文件中的第一个对象是:

for i in stride(from: 10, through: 5, by: -1) { print(i) }

代替:

if (firstChoice === secondChoice) {
    match_count += 1;
    match_empty = true;
    $.ajax({
        url: '../webpro/scripts/add_match.php',
        type: 'POST',
        data: { "data" : firstChoice },
        success: function (data)
        {
            console.log(data);
        }
});

等 它需要蜜蜂,因为下面的代码不能对其进行迭代。

"data":"dog"

代码add_match.php:

"0":{"data":"dog", "1":{"data": "bee"}

希望你能帮助我 谢谢

0 个答案:

没有答案