如何使用onchange事件在javascript ajax调用中传递HtmlHelper下拉列表的值?

时间:2014-08-11 07:27:09

标签: ajax asp.net-mvc-3

我想在ajax调用中传递下拉列表的Htmlhelper帮助值

      @Html.DropDownListFor(m => m.LanguageRouteName, (SelectList)ViewBag.LanguageEnum, new { @onchange = "submitform(event)", @class = "input-medium", @id = "languageEnum" })

我正在尝试传递该事件,但我需要HtmlHelper' helper'的所有值。我如何获得这个价值?请帮忙

1 个答案:

答案 0 :(得分:0)

$( '#languageEnum')。平变化(函数(){

var ddl val = $('#languageEnum')。val();

$。AJAX({                     键入:“GET”,// GET或POST或PUT或DELETE动词

                url: ajaxUrl,       // Location of the service

               data: "ddldata:ddl",         // dropdown data 

                dataType: "json",   //Expected data format from server

                success: function (json) {//On Successful service call
                    var result = json.name;
                    $("#dvAjax").html(result);
                }

})

});