javascriptはjsonページの区切りの実例コードを実現します.

3963 ワード

午後友達がjsonのデータをどうやって分けたらいいですか?
次の直接コード:
 
  





<br>var a={"code":1,"list":[{"category1_id":"1","category1_name":"\u9152\u6c34\u996e\u6599","category1_intro":"\u6e05\u51c9\u53ef\u53e3\u7684\u9152\u6c34\u996e\u6599","category1_images":"http:\/\/www.songcuomen.com\/attachments\/productType\/2014-01\/10\/21_1389343628.jpg"},{"category1_id":"2","category1_name":"\u7c73\u9762\u7cae\u6cb9","category1_intro":"\u5bb6\u5ead\u5fc5\u5907","category1_images":"http:\/\/www.songcuomen.com\/attachments\/productType\/2014-01\/10\/21_1389343865.jpg"},{"category1_id":"3","category1_name":"\u7f8e\u5bb9\u6d17\u62a4","category1_intro":"\u62a4\u80a4\u5fc5\u5907","category1_images":"http:\/\/www.songcuomen.com\/attachments\/productType\/2014-01\/10\/21_1389343935.jpg"},{"category1_id":"4","category1_name":"\u6e05\u6d01\u6d17\u6da4","category1_intro":"\u7ed9\u60a8\u4e00\u4e2a\u5e72\u51c0\u7684\u751f\u6d3b\u73af\u5883","category1_images":"http:\/\/www.songcuomen.com\/attachments\/productType\/2014-01\/10\/21_1389343986.jpg"},{"category1_id":"5","category1_name":"\u751f\u6d3b\u7528\u54c1","category1_intro":"\u5bb6\u5ead\u5fc5\u5907","category1_images":"http:\/\/www.songcuomen.com\/attachments\/productType\/2014-01\/10\/21_1389344445.jpg"},{"category1_id":"6","category1_name":"\u4f11\u95f2\u98df\u54c1","category1_intro":"\u597d\u5403\u7f8e\u5473","category1_images":"http:\/\/www.songcuomen.com\/attachments\/productType\/2014-01\/10\/21_1389344494.jpg"}]}; <br>var y=1;// <br>var t=2;// <br>var z=a["list"].length; <br>var zy= Math.ceil(z/t); <br>window.onload=function (){ <br>fanye(0); <br>} <br>function fanye(f) <br>{ <br>    if(y==1 && f==-1) <br>    { <br>        alert(' '); <br>        f=0; <br>        } <br>    if(y==zy && f==1) <br>    { <br>        alert(' '); <br>        f=0; <br>        }    <br> <br>     var otbod=document.getElementById('table').tBodies[0]; <br>     var s=otbod.rows.length; <br>    for(i=0;i<s;i++) <br>    { <br> <br>        otbod.removeChild(otbod.rows[0]); <br>    } <br>        y+=f; <br>       var q=(y-1)*2;// -1 <br>       for(var i=1;i<3;i++) <br>    { <br> <br>    var otr=document.createElement('tr'); <br>    var otd1=document.createElement('td'); <br>    var otd2=document.createElement('td'); <br>    var otd3=document.createElement('td'); <br>    var otd4=document.createElement('td'); <br>    otd1.innerHTML=a["list"][q]['category1_id']; <br>    otd2.innerHTML=a["list"][q]['category1_name']; <br>    otd3.innerHTML=a["list"][q]['category1_intro']; <br>    otd4.innerHTML=a["list"][q]['category1_images']; <br>    otr.appendChild(otd1); <br>    otr.appendChild(otd2); <br>    otr.appendChild(otd3); <br>    otr.appendChild(otd4); <br>     otbod.appendChild(otr); <br>     if(q==zy) <br>     { <br>         break; <br>         } <br>    q++; <br>    } <br>} <br>




category1_idcategory1_namecategory1_introcategory1_images

のページ
のページ