How to create html page in the ajax response in jQuery -


we using jquery ajax in our application.

for example states in country ,after getting result server doing following thing.

$.each(results , function(index,value){    $('#id').append('<option value="'+index+'">'+value+'</option>');  });//here `id` select box id 

it working perfectly. need better readable solution. there other way this?

just simple optimization should enough:

(function () {     var str = "";     $.each(results, function (index, value) {         str += '<option value="' + index + '">' + value + '</option>';     });     document.getelementbyid('id').innerhtml += html; })(); 

Comments

Popular posts from this blog

php - Why I am getting the Error "Commands out of sync; you can't run this command now" -

linux - Does gcc have any options to add version info in ELF binary file? -

java - Are there any classes that implement javax.persistence.Parameter<T>? -