首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > Ajax >

JQ 里头each的用法

2013-12-30 
JQ 里面each的用法function add() {$.ajax({type: get,url: DB.ashx,data: {},datatype: json,succe

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是表的列明(应该能只读其中几行吧,还有好多列没读的),然后输出到页面全是 没定义的

[解决办法]
楼主可以看下这个

热点排行