$ .each遍历ajax成功未定义问题

时间:2018-09-06 23:13:39

标签: jquery ajax typeerror

我的程序在请求后回显一个json_encoded数组,如下所示

[{
"id": "1",
"soal": "<span class=\"math-tex\">\\(۰\\text{/}۰۲\\,mol.{{L}^{-۱}}.{{min }^{-۱}}\\)</span>",
"gozineh1": "<p>7/5</p>",
"gozineh2": "<p>15</p>",
"gozineh3": "<p>30</p>",
"gozineh4": "<p>60</p>",
"difficulty": "1",
"type": "1",
"field": "2"
}
 ,{
"id": "2",
"soal": "<span class=\"math-tex\">\\(۰\\text{/}۰۲\\,mol.{{L}^{-۱}}.{{min }^{-۱}}\\)</span>",
"gozineh1": "<p>7/5</p>",
"gozineh2": "<p>15</p>",
"gozineh3": "<p>30</p>",
"gozineh4": "<p>60</p>",
"difficulty": "1",
"type": "1",
"field": "2"
}]

并且我试图在警报中显示它,并且我的代码以前像下面的

      $.ajax({
        type: 'POST',
        url: '/////',
        data: {'///'},
        dataType: "json",
        success: function(data) {
            $.each(data, function() {
                $.each(this, function(k, v) {
                    alert(k[v].id);
                });
            });
        }
    })
});

这是我每次都会遇到的错误

  

未被捕获的TypeError:无法使用'in'运算符在数组中搜索'length'
  (
      [0] =>数组
          (
              [id] => 1
  ....

0 个答案:

没有答案