데이터베이스 호출에서 만드는 자바 스크립트 개체가 있습니다. 여러 항목이있을 것이므로 특정 키/값 (moduleID)으로 참조 할 수 있어야합니다. 대신에 내가 무엇을 찾고 찾을 각각을 통해 루프를 갖는자바 스크립트 개체에서 데이터 찾기
success: function(data) {
// Define our local vars
var moduleIncludes = Array();
// Loop over each of the users selected modules and put them into an array
$(data).find('modules').each(function() {
// Push module JS file names to an array
moduleIncludes.push($(this).find('moduleJSFile').text());
// Create an object of module data
moduleData.push({
moduleID: $(this).find('moduleID').text(),
moduleRow: $(this).find('row').text(),
moduleColumn: $(this).find('col').text(),
moduleName: $(this).find('moduleName').text(),
moduleDescription: $(this).find('moduleDescription').text(),
moduleJSFile: $(this).find('moduleJSFile').text(),
moduleIcon: $(this).find('moduleIcon').text(),
moduleStartingXsize: $(this).find('startingXsize').text(),
moduleStartingYsize: $(this).find('startingYsize').text(),
moduleResizeLocked: $(this).find('resizeLocked').text(),
moduleMinXsize: $(this).find('minXsize').text(),
moduleMinYsize: $(this).find('minYsize').text()
});
});
// Using our array of modules, fetch them to include them into the page
$.getMultiScripts(moduleIncludes, 'includes/js/modules/').done(function() {
// All of the modules have been included. Trigger the grid functionality.
renderCanvas();
});
}
});
, 내가 대신 고유 한 이후 moduleID
에 의해 개체의 이름을 수있는 방법은 무엇입니까?
예를 들어, moduleId 1에 관련된 모든 데이터를 보려면 루프로 찾기보다는 ID로 개체를 검색하고 싶습니다.
작성시이 작업을 수행 할 수 있습니까?
'데이터'형식의 예를 보여줄 수 있습니까? 배열을 가지고 있다면 그것을 반복하거나 ('.find()'또는'.filter()'를 사용한다), 객체가 있다면 키 이름으로 속성을 참조 할 수있다. – nnnnnn
데이터는 저장 프로 시저에서 전달 된 XML 문자열입니다. 개체는 이미지에서 볼 수있는 것처럼 잘 생성되지만 ID로 정의해야합니다. – SBB