使用jquery在Mvc 4.0中级联下拉列表 [英] Cascading dropdown lists in Mvc 4.0 using jquery

查看:81
本文介绍了使用jquery在Mvc 4.0中级联下拉列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

<script type="text/javascript" >
            $(document).ready(function(e) {

                $("#State").change(function (e) {

                    var selectedValue = $(this).val();
                    if(selectedValue != "Select") {
                        $.ajax({
                            url: '@Url.Action("GetCities","Employer")',
                            type: 'Post',
                            //data:  { "selectedValue": selectedValue},
                            data: {id: $("#State").val()},
                            dataType: 'json',
                            success: function(response) {
                                var items = "";
                                $.each(response, function(i, city) {
                                    $("#City").append('<option value="' + city.Value + '">' + city.Text + '</option>');
                                });
                            },
                            error: function (ex)
                            {
                                alert("Failed To Receive States" + ex);
                            }
                        });  
                    }
                }) 
            })

        </script>

推荐答案

document )。ready( function (e){
(document).ready(function(e) {

#State)。change( function (e){

var selectedValue =
("#State").change(function (e) { var selectedValue =


this )。val();
if (selectedValue!= 选择){
(this).val(); if(selectedValue != "Select") {


这篇关于使用jquery在Mvc 4.0中级联下拉列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆