에 나는 JQuery와에 내가 아주 간단한 예제를 만들기 위해 노력하고채우기 JQuery와 콤보 상자는 MVC3
MVC 3에 새로운입니다.
jquery 콤보 박스가 있는데 페이지로드 중에 일부 데이터로 채워 넣고 싶습니다.
클라이언트
$(function() {
$("#combobox").combobox({
// initialValues: ['array', 'of', 'values'],
source: function (request, response) {
if (!request.term.length) {
response(_self.options.initialValues);
} else {
if (typeof _self.options.source === "function") {
_self.options.source(request, response);
} else if (typeof _self.options.source === "string") {
$.ajax({
url: "/dropdown/GetList",
//data: request,
dataType: "json"
//success: function (data, status) {
// response(data);
//},
//error: function() {
// response([]);
// }
});
}
}
}
});
$("#toggle").click(function() {
// $("#combobox").toggle();
});
});
**Function in Controller**
[HttpGet]
public JsonResult GetList()
{
try
{
Employee objName = new Employee();
objName.Name = "Test";
List<Employee> objectList = new List<Employee>();
objectList.Add(objName);
return Json(new { Records = objectList, TotalRecordCount = 1 });
}
catch (Exception ex)
{
return Json(new { Result = "ERROR", Message = ex.Message });
}
}
내가 서버 측 함수에서 중단 점을 넣어 가지고 있지만, 거기에 도달하지 :
그래서 여기에 코드입니다. 정말 감사드립니다. 당신의 URL에 대해서는 고급의
감사합니다, V
안녕하세요, 답장을 보내 주셔서 감사드립니다. –
URL과 actioname은 모두 정확합니다. 그러나, 내가 방금 추천 한 기사를 읽을 것입니다. –
예, 저도 노력했습니다. 문제는 그것을 콤보 상자에 바인딩하는 방법입니다. –