php ,ajax 二级联动,求思路,求代码

用ajax写一个二级联动,不需要数据库,说一下思路,新人求代码

类似下面这样,实际多少级联动都差不多,关键事件触发ajax,然后获取数据进行加载
http://blog.csdn.net/shunyea/article/details/8443902 数据库
http://www.thinksaas.cn/group/topic/346669/ 无数据库

可以存session,或者存在application(java ee 里面的,不知道php里面有没有)

数据量不大直接生成客户端js数据就好了。。

 <title>javascript省市联动示例</title>
省:<select id="pro"><option value="">请选择省</option>
<option value="1">北京</option>
<option value="2">上海</option>
<option value="3">广西</option></select>
市:<select id="city"><option value="">请选择市</option></select>
<script>
    //市数据结构,为json数组对象。数组小标为省的id,数组项为市json数据。如果还有县的联动,同理生成arrTown即可。
    var arrCity = [];
    arrCity[1] = [{ t: '北京市', id: 1}];
    arrCity[2] = [{ t: '上海市', id: 2}];
    arrCity[3] = [{ t: '南宁市', id: 3 }, { t: '桂林市', id: 4 }, { t: '柳州市', id: 5}];
    document.getElementById('pro').onchange = function () {
        addOptions(document.getElementById('city'), arrCity[this.value]);
    }
    function addOptions(s, arr, initValue) {
        if (!arr || arr.length == 0) arr = [{ t: '请选择市', id: ''}];
        if (!s) { alert('select对象不存在!'); return false }
        s.options.length = 0;
        var selectedIndex = 0;
        for (var i = 0; i < arr.length; i++) {
            s.options.add(new Option(arr[i].t, arr[i].id));
            if (arr[i].id == initValue) selectedIndex = i;
        }
    }
</script>

ecshop 里面有关于区域的引用可以参考一下