There is my code:
$.ajax({
url: "?module=gestionApplication&action=importScenario&fichierconf="+$fichierconf,
dataType: "json",
success: function( data ) {
$( "#dialog-scenario input#fichierxml" ).val( data.FICHIERXML );
$( "#dialog-scenario input#fichierproxy" ).val( data.FICHIERPROXY );
$( "#dialog-scenario select#portail" ).val( data.PORTAIL );
$( "#dialog-scenario select#typemaj" ).val( data.MONITORING );
$( "#dialog-scenario input#periodemaintenance" ).val( data.MAINT );
$( "#dialog-scenario input#nomdns" ).val( data.DNSATESTER );
It works well, but i got like 40 lines of the same type is it possible to do the same action without knowing the string after data. ?
I would do something like
data.each( function(dataName) {
$( "#dialog-scenario inputORselect#"+dataName ).val( data.dataname );
});
Thx for your help
Create a map between the name of the element and the data property:
Then you can loop through the properties to set their values.