从Json数组发出打印值

时间:2016-10-12 05:56:41

标签: jquery html

我正在尝试将JSON数据库中的值打印成2个单独的div标签,但我不断向我发出语法错误



var response;
var urlstring = "http://dev.xxxxxxx.com/llp/n.php?grade=3&subject=math&state=NJ";

$(document).ready(function() {
  $("#math").click(function() {

    $.ajax({
      url: urlstring,
      type: 'GET',
      error: function(jqXHR, text_status, strError) {
        alert("no connection");
      },
      timeout: 60000,
      success: function(response) {
        for (var i = 0; i < response.error.length; i++) {
          '<ul>'
          $('<li>' + response.error[i].LessonName + '</li>').appendTo("#listoftopics").trigger('create');
          for (var x = 0; x < response.error[i].no_of_questions.length; x++) {
            $("Locked Questions : " + " " + response.error[i].no_of_questions[x].Locked + " " + "Unlocked Questions :" + " " + response.error[i].no_of_questions[x].Unlocked + '<br/>' + '<hr>').appendTo("#questNo");

          }
          '</ul>'
        }
      }

    });

  });

})
&#13;
<div id="listoftopics" style="width:100%;">
  - List of subjects
</div>
<div id="questNo" style="width:100%;">
  - Locked Questions
</div>
&#13;
&#13;
&#13;

我的问题是它只打印循环中的第一项并触发错误

0 个答案:

没有答案