日期:2014-05-16  浏览次数:20886 次

JQ 里面each的用法

function add() {

            $.ajax(
          {
              type: "get",
              url: "DB.ashx",
              data: {  },
              datatype: "json",
              success: function (data) {
                  alert(data); //这里我已经测试出来了 这个JSON的data是没有问题的
                  $.each(data, function (index, p) {  //关键是怎么each循环读出来
                      var html = "<div>" + p.SI_shop_no + p.SI_shop_title + "</div>";
                      $("#div1").append(html);
               });
              },
              error: function () {
                  alert("error");
              }
          });
        }



$.each 我没用过,这个方法我是抄课本的,我甚至不知道 function(index,p)这两个参数干什么的,
SI_shop_no  SI_shop_title是表的列明(应该能只读其中几行吧,还有好多列没读的),然后输出到页面全是 没定义的

------解决方案--------------------
楼主可以看下这个