【发布时间】:2019-01-24 08:06:27
【问题描述】:
我使用 Jquery 从数据库中检索记录,其中值和复选框附加在 div 上, 我目前希望在检索此记录时检查数据库中 ID 为 = 5 的记录。 请任何帮助
以下是检索记录并将每条记录附加到 div 中的代码。
function loadState(xxxxxxTypeDDL) {
if ($(xxxxxxTypeDDL).val() == "") {
clearState(xxxxxxTypeDDL);
return;
}
$.ajax({
url: "/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
global: false,
cache: false,
dataType: 'json',
timeout: 30000,
beforeSend: function() {
$("#ajax-loading-placeholder").html('<img src="/Images/ajax-loader.gif" alt="...Loading" /> ...Loading').dialog({
autoOpen: false,
width: 32,
height: 60,
modal: true,
resizable: false
}).dialog("widget").find(".ui-dialog-titlebar").remove();
// alert("Weldone Dude");
$("#ajax-loading-placeholder").dialog('open');
clearState(xxxxxxTypeDDL);
},
success: function(data) {
$('#ajax-loading-placeholder').dialog('destroy').html('');
var htmlToInsert = "";
if (data == null) {
$("<div></div>").text("No State found matching your selection criteria").dialog({
autoOpen: false,
modal: true,
title: 'Select Required State',
buttons: {
"Ok": function() {
$(this).dialog('destroy').html('');
}
}
}).dialog("open");
clearState(xxxxxxTypeDDL);
$(xxxxxxTypeDDL).val("");
$("#selected-state").hide();
return;
}
$(data.State).each(function() {
var input = "<div style='margin-bottom:5px' class='retrieved-state-list'><input type='checkbox' id='";
input += "RetrievedState' value='";
input += this.ID;
if ($.inArray(this.ID.toString(), data.SelectedState) > -1) {
input += "' checked='checked";
}
input += "' </input><span style='display:none'>" + this.Name + "</span>";
input += "<span>" + this.Description + "</span></div>"
htmlToInsert += input;
});
【问题讨论】:
-
我认为是因为您在这里没有正确形成输入标签。检查后您没有关闭“>”输入
标签: jquery sql-server asp.net-mvc