虽然我试图在插入数据后显示列表页面,但它不起作用。
html代码: -
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>iDNS rule engine</title>
</head>
<body>
<script type="text/javascript">
var studioName={};
var configurationObject={};
</script>
//my html access codes
</body>
</html>
从数据库获取所有详细信息功能: -
function getAllConfigurationRules(){
$.ajax({
url : "http://localhost:8080/IDNS_Rule_Configuration/idns/idnsData/getAllConfigurationRules",
type : "GET",
dataType : "json",
success : function(data){
studioName={};
studioName=data;
loadAllConfigurationRuleName();
selectRuleBoxLoadDetails();
}
});
}
上面的显示studioName是全局对象。
loadAllConfigurationName()函数: -
function loadAllConfigurationRuleName(){
$('#serviceRules').html("");
allRuleNames=[];
for(var i=0;i<studioName.length;i++){
var dataId = studioName[i].ruleId;
var dataArray = studioName[i].ruleName;
allRuleNames[i]=studioName[i].ruleName;
if(studioName[i].ruleStatus == true){
var dataSelect=studioName[i].ruleId;
}else{
var dataSelect = 0;
}
$('#serviceRules').populate1(dataId, dataArray, dataSelect);
}
}
populate1: -
$.fn.populate1 = function(dataId, dataArray, dataSelect) {
console.log("data Select Value = "+dataSelect);
var $selectbox = $(this);
// check if eleme nt is of type select
if ($selectbox.is("select")) {
if(dataSelect != 0){
$selectbox.append('<option selected value="' + dataId
+ '" stream="' + dataId + '">'
+ dataArray + '</option>');
}else{
$selectbox.append('<option value="' + dataId
+ '" stream="' + dataId + '">'
+ dataArray + '</option>');
}
}
};
selectRuleBoxLoadDetails函数: -
function selectRuleBoxLoadDetails(){
//some code for where i show using table
}
插入功能: -
$("#uploadfile").click(function(){
var file = $('input[name="uploadfile"').get(0).files[0];
var formData = new FormData();
formData.append('uploadfile', file);
$.ajax({
type : 'POST',
url : 'http://localhost:8080/IDNS_Rule_Configuration/idns/idnsData/importYaml', //Server script to process data
enctype : 'multipart/form-data',
data : formData,
processData : false,
contentType : false,
success : function(data) {
$.when( getAllConfigurationRules() ).done(function() {
importPopulateFunction(data);
selectRuleBoxLoadDetails();
});
/* getAllConfigurationRules(function(e){
e.preventDefault();
importPopulateFunction(data);
selectRuleBoxLoadDetails();
});/*
}
});
});
importPopulateFunction函数: -
function importPopulateFunction(comingRuleName){
$('#fileupload').val('');
$('#fileuploadstatus').html('yaml uploaded successfully.');
$('#fileuploadstatus').css({'color':'green'});
$(".config-add").hide();
$(".import-yaml").hide();
$(".config-view").show();
$('#serviceRules').html("");
for(var i=0;i<studioName.length;i++){
var dataId = studioName[i].ruleId;
var dataArray = studioName[i].ruleName;
var dataSelect = studioName[i].ruleId;
if(studioName[i].ruleName == comingRuleName){
$('#serviceRules').populate1(dataId, dataArray, dataSelect);
}else{
$('#serviceRules').populate1(dataId, dataArray, 0);
}
}
}
亲切的帮助我解决这个问题。谢谢。