Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8391963
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T19:23:43+00:00 2026-06-09T19:23:43+00:00

There is my code: $.ajax({ url: ?module=gestionApplication&action=importScenario&fichierconf=+$fichierconf, dataType: json, success: function( data ) {

  • 0

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

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T19:23:45+00:00Added an answer on June 9, 2026 at 7:23 pm

    Create a map between the name of the element and the data property:

    var map,
        prop;
    
    map = {
        "typemaj" : "MONITORING",
        "periodemaintenance" : "MAINT"
    }
    

    Then you can loop through the properties to set their values.

    for( prop in map ) {
        $( "#dialog-scenario inputORselect#" + prop ).val( data[ map[prop] ] );
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here's the code: $.ajax({ url:http://.....pullEntireDBPopulation.php, cache:false, datatype:json, success:function(popData){ alert(Population size: + popData.length); popProducers =
I have some very simple sample code like this: $.ajax({ url: 'demo2.htm', success: function(loadeddata){
I have an Ajax request: $.ajax({ url: MyPage.aspx, data: params, success: function(data) { //
This is my code: $.ajax({ url: someUrl, type: PUT, data: { id: id, message:
In my javascript code I have the following: function SelectTopics() { $.ajax({ url: /Administration/Loc/SelectTopics,
I am having trouble getting a success: function(){} working - the ajax code I
Hi guys i have the following code $.ajax({ url: http://localhost/twee/chat/getnumcom, type: 'POST', data: form_data,
I have seen the following sequence in my client code: $.ajax({ url: ..., data:
Ho do you reference code inside an AJAX tabcontainer? Is there an easy way?
There is currently this Prototype code that does a PUT: new Ajax.Request(someUrl, { method:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.