json作为轻量级的交互技术,未来有替代xml的趋势,而且作为javascript的子集,更方便前台处理!

[{pid:"10",province:"安徽"},{pid:"11",province:"北京"},{pid:"12",province:"福建"},{pid:"13",province:"甘肃"},{pid:"14",province:"广东"},{pid:"15",province:"广西"},{pid:"16",province:"贵州"},{pid:"17",province:"海南"},{pid:"18",province:"河北"},{pid:"19",province:"河南"},{pid:"20",province:"黑龙江"},{pid:"21",province:"湖北"},{pid:"22",province:"湖南"},{pid:"23",province:"吉林"},{pid:"24",province:"江苏"},{pid:"25",province:"江西"},{pid:"26",province:"辽宁"},{pid:"27",province:"内蒙古"},{pid:"28",province:"宁夏"},{pid:"29",province:"青海"},{pid:"30",province:"山东"},{pid:"31",province:"山西"},{pid:"32",province:"陕西"},{pid:"33",province:"上海"},{pid:"34",province:"四川"},{pid:"35",province:"天津"},{pid:"36",province:"新疆"},{pid:"37",province:"西藏"},{pid:"38",province:"云南"},{pid:"39",province:"浙江"},{pid:"40",province:"重庆"},{pid:"41",province:"香港"},{pid:"42",province:"澳门"},{pid:"43",province:"台湾"},{pid:"44",province:"国外"}]

<!--通过json同步获取省份开始-->
    function loadprovincejson()                                                                                   
    {                                                                                                             
      var myajax = new ajaxsz();                                                                                
     var province = myajax.sendData("POST","http://localhost:5964/GetData/GetJson.aspx",false,"");             
                                                                                                                 
      eval("jsonstr = " + province);                                                                            
                                                                                                                
       //alert(jsonstr[0].province);                                                                             
                                                                                                                  
       var select3 = document.getElementById("Select3");                                                         
                                                                                                            
                                                                                                            
     for (i = select3.length; i >= 0; i--)                                                                    
     {                                                                                                         
               select3.remove(i);                                                                                
           }                                                                                                         
                                                                                                              
          select3.options.add(new   Option("---选择省份---","0"));                                                  
                                                                                                            
      for(i=0;i<jsonstr.length;i++)                                                                            
       {                                                                                                         
            var newOption = document.createElement("OPTION");                                                     
            newOption.text=jsonstr[i].province;                                                                   
            newOption.value=jsonstr[i].pid;                                                                       
            select3.options.add(newOption);                                                                      
     }                                                                                                         
    }                        
<!--通过json同步获取省份结束-->    

GitHub 加速计划 / js / json
18
5
下载
适用于现代 C++ 的 JSON。
最近提交(Master分支:2 个月前 )
960b763e 5 个月前
8c391e04 8 个月前
Logo

旨在为数千万中国开发者提供一个无缝且高效的云端环境,以支持学习、使用和贡献开源项目。

更多推荐