Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

207
Views
Ajax Response Datos JSON para seleccionar el cuadro en html

a continuación está mi llamada ajax y obtengo datos r JSON

 $.ajax ({ type: "POST", url: "getrecieverlist.php", data: { strSenderID: sendmeid }, success: function (r) { } });

Recibo respuesta r como datos JSON a continuación

 { "receiverDetails": [ { "receiver_id": "55555", "name": "Nitin", "mobile": "7777777777", "ifsc_code": "IFSC54545", "acc_no": "16-01-2017" }, { "receiver_id": "66666", "name": "Vikram", "mobile": "9191919191", "ifsc_code": "IFSC54545", "acc_no": "13-01-2017" } ], "success": 1 }

y mi código html de cuadro de selección está debajo

 <select id="recieverlist" name="select" class="main-form"> <option value="">None Selected</option> </select>

lo que quiero es completar las opciones del cuadro de selección con el texto como nombre de los datos JSON y el valor de las opciones para ser ID de receptor, probé muchas cosas pero no funcionó para mí, ¿necesito la guía adecuada sobre cómo hacerlo?

about 4 years ago · Santiago Trujillo
2 answers
Answer question

0

Intente seguir.

 success : function (r) { var data = r.receiverDetails; var options = ''; for(var i=0; i<data.length; i++) { // Loop through the data & construct the options options += '<option value="'+data[i].receiver_id+'">'+data[i].name+'</option>'; } // Append to the html $('#recieverlist').append(options); }
about 4 years ago · Santiago Trujillo Report

0

También puede $.cada función.

 $.each(data.receiverDetails, function(index, value) $("#recieverlist").append('<option value="'+value.receiver_id+'">'+value.name+'</option>'); });
about 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!