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
Post a Comment