0
我使用下面的JavaScript函數來填充Datalist
:填充數據
function GetDropDownData(f) {
$.ajax({
url: '/Rentals/Base/GetContactsForFacility?selectedFacility=' + f,
data: { facility: f },
dataType: 'json',
success: function (result) {
response($.map(result, function (item) {
$('#custServiceContactsSelection').append($("<option />").val(item.ContactName).text(item.ContactName));
}));
},
cache: false,
error: function (jqXHR, textStatus, errorThrown) {
if (errorThrown.indexOf("Your session has timed out") != -1) {
location.href = "/Rentals/Base/Timeout";
}
}
});
}
以下是我的控制器內的方法:
public ActionResult GetContactsForFacility (string selectedFacility)
{
var facilityId = new Guid(selectedFacility);
if (Request.IsAjaxRequest())
{
var contacts = SessionService.AllCustomerServiceContactsForFacility(CrmService, facilityId);
return Json(contacts.Select(x => new { label = x.ContactName }), JsonRequestBehavior.AllowGet);
}
return Content(string.Empty);
}
當我試圖運行這一點,從Controller返回。但是,之後,我在我的VS中出現錯誤: JavaScript runtime error: 'response' is undefined
我認爲,函數GetDropDownData()
中缺少某些內容,但無法弄清楚究竟是什麼。
請問你能指導我嗎?謝謝!
感謝您的答覆!至少,錯誤已經消失。但是,我仍然無法看到數據主義者。讓我得到這個工作,我會讓你知道(並將此標記爲答案!)。 :) – Vikram 2014-10-02 16:00:33
這是關於同樣的事情。我無法在用戶界面中看到數據專家。它說「驗證(XHTML 1.0過渡):Element'datalist'不被支持'。那麼,有沒有其他的替代方案可以使用,它類似於'datalist'並捕獲發送的響應? – Vikram 2014-10-02 17:31:19