$(document).ready(function() {
            GetRegion(); 
            $("#region").change(function() { GetProvince() });
        });        function GetRegion() {
            $("#region").empty();
            var url = "/ISC/GetRegion/";
//            $("#region").append("<option value='00'>" + "请选择…" + "</option>");
            $.getJSON(url, function(data) {
                $.each(data, function(i, item) {
                    $("<option></option>")
                .val(item["Value"])
                .text(item["Text"])
                .appendTo($("#region"))
                });
                GetProvince();
            });
        }        function GetProvince() {
            $("#province").empty();
            var url = "/ISC/GetProvince/" + $("select[@name=" + region + "] option[@selected]").text();
            $.getJSON(url, function(data) {
                $.each(data, function(i, item) {
                    $("<option></option>")
                .val(item["Value"])
                .text(item["Text"])
                .appendTo($("#province"));
                });
            });
        }  
其中的$("select[@name=" + region + "] option[@selected]").text();对不对呢?
还有整个二级级联有问题吗?后台始终拿不到select中的文本内容。

解决方案 »

  1.   

    <select id="region" name="region"></select>
    <select id="province" name="province"></select>
      

  2.   

    $("select[@name=" + region + "] option[selected]").text()
      

  3.   

    var url = "/ISC/GetProvince/" + $("select[@name=" + region + "] option[selected]").text();后台是不是只要GetProvince(string region)就能拿到了?
      

  4.   

    $("#selectId").val();
    $("#selectId option:selected").text();
      

  5.   

    我通过public ActionResult GetProvince(string regionName)
    获取到得regionName是个空值额
      

  6.   

    如果JQuery是1.3版本的 $("select[@name=" + region + "] option[@selected]").text();中不需要“@” 老版本才需要“@”
    正确写法:
    $("select[name='region'] option[selected]").text();
    或者如楼上所说:$("#region option:selected").text();
      

  7.   

    这个还有版本问题
    var regionName = $("#region option:selected").text();
    var url = "/ISC/GetProvince/" + regionName;那我后台是用
    string regionName = Request.Params["regionName"];
    还是
    string regionName = Request.Params["region"];
    呢?
    好像都不行