0
我似乎無法讓我的周圍Ajax和JSONmvc4:級聯下拉
的頭,我想要做一個級聯下拉,我試圖將數據得到一個div,開始了。 這裏是腳本
<script src="~/Scripts/jquery-ui-1.8.20.js"></script>
<script src="~/Scripts/jquery-ui-1.8.20.min.js"></script>
<script>
$(function() {
$('#funtiontype').change(function() {
var selectedValue = $(this).val();
$.ajax(
{
// url: $(this).data('url'),
// source: "/EmployeeReps/GetDescription",
url: "~/EmployeeReps/GetDescription",
type: 'GET',
cache: false,
data: {value: selectedValue },
success: function (result) {
$('#description').html(result.employeelist);
}
});
});
});
</script>
而且控制器
[AcceptVerbs(HttpVerbs.Get)]
public ActionResult GetDescription(string value)
{
//get the data from DB
var employeelist =(from s in db.tble_employeeReps where s.em_function==value
select s);
return Json(employeelist.ToList(), JsonRequestBehavior.AllowGet);
}
的HTML @using(Html.BeginForm()){
<fieldset>
<div class="editor-label">Function*</div>
<div class="editor-field">
<select id = "funtiontype">
<option value = "">Please Select</option>
<option value = "Finance">Finance</option>
<option value = "Non-Finance">Non-Finance</option>
</select>
</div>
<p></p>
<p>
<input type="submit" value="Vote" />
</p>
</fieldset>
<div id="description"></div>
}
但我努力讓任何數據。請誰能幫助
很多感謝 碎甲彈
http://stackoverflow.com/questions/4458970/cascading-drop-downs-in-mvc-3-剃刀查看 – 2013-03-27 17:40:52