上一篇: 下一篇:

jQuery之json用法之一

2010年08月17日  |  08:14分类:jQuery  |  标签:  |  742 views

//构造json   字符串

$depStr = “”;
//   print_r($arr1);
   $depStr .= “{ root: [ {";
   $count = sizeof($arr1);
   for($i=1;$i<$count;$i++){
    if($arr1[$i] !=”" && $arr1[$i] != null){       
      $depStr .= ‘”‘.$arr2[$i].’”:”‘.$arr1[$i].’”,’;    
    }
   }
   $depStr =  str_replace($depStr,”",substr($depStr,0,-1));
   $depStr .= “} ] }”;
   
   return $depStr;

//显示信息   
    $.post(‘organization/?action=displayDepartment&depID=’+depID,function(data,textStatus){
//    alert(data);
    var dataObj=eval(“(“+data+”)”);//转换为json对象
    $.each(dataObj.root[0],function(index,item){  
    //输出每个root子对象的名称和值
    $(‘#ModifyDepartmentForm :input[id="'+index+'"]‘).val(item);
    });
    
    },’text’);

原创文章,转载请注明: 转载自长沙营销型网站建设,营销型网站开发,Zen-Cart | 小龙包

本文链接地址: jQuery之json用法之一

喜欢本文,那就收藏到: Del.icio.us Google书签 Digg Live Bookmark Technorati Furl Yahoo书签 Facebook 百度搜藏 新浪ViVi 365Key网摘 天极网摘 和讯网摘 博拉网 POCO网摘 添加到饭否 QQ书签 Digbuzz我挖网

1条评论 关于 “jQuery之json用法之一”

  1. 玎蕾 发表于: 八月 18th, 2010 11:47

    学习了


发表您的评论

*
To prove you're a person (not a spam script), type the security word shown in the picture. Click on the picture to hear an audio file of the word.
Click to hear an audio file of the anti-spam word