ajax遍历省份转换成拼音,山西与陕西拼音相同,怎么区分?求解答

$(function () {        var shanxiArr = [];
        $.ajax({
            url: 'city.php',
            type: 'get',
            dataType: 'json',
        })
        .done(function(data) {
            $.each(data, function(i, province) {              var provinceName = i.substring(0,2);              var province_pinyin = ConvertPinyin(provinceName);    

              if ("shanxi" == province_pinyin) {
                  shanxiArr.push(province_pinyin);
                  console.log(shanxiArr);

                }                // console.log(province_pinyin);
              var h3Item = "<li  class='fl'> <a href='http://www.reading-china.com/"+province_pinyin+"' target='_blank' rel='external nofollow'>"+province_name+"</a> </li>";
              $('#cheng_shi').append(h3Item);
            });

        })
        .fail(function() {
            console.log("error");
        });
    })

我想取出shanxi添加到数组,然后把数组[1]==shanxixi,可是我遍历出来的怎么是循环了两遍?我怎么把陕西的拼音改成shanxixi  ?


qq_遁去的一_1
浏览 744回答 1
1回答

呼如林

陕西 Shaanxi山西 Shanxi
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

JavaScript