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

279
Views
How to append the json results to select dropdown using php jax?

I have list of json results but cant get into select html tried the following code

Json ouput: jquery loop on Json data using $.each

{"Eua":"Eua","Ha'apai":"Ha'apai","Niuas":"Niuas","Tongatapu":"Tongatapu","Vava'u":"Vava'u"}

 success: function(result){
                    
                    console.log(data);
                    var data = jQuery.parseJSON(result);
                    jQuery.each(data,function(key, value)
                {   //jQuery("#state").html();
                    console.log(key);
                    jQuery("#state").html('<option>'+value+'</option>');
                })
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Using the instruction

jQuery("#state").html(...)

would replace the previous option with new one, so you will always get only one option, which is the last Json value.

You should use

jQuery("#state").append(...)

This instruction would append an option to the select dropdown, remaining the previous options in place.

about 4 years ago · Juan Pablo Isaza 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!