json - Refresh dropdown with Jquery -


i have 1 dropdown displaying month january current month in jquery mobile. i'm getting data using json. problem selected option not getting refresh.

$.ajax({     type: "post",     url: "../modules/loadmonth.php?id=getoption&studid=" + $('#studentids').val(),     contenttype: "application/json; charset=utf-8",     datatype: "json",     success: function (data) {         $.each(data, function (i, item) {             var sel;             if (date[i].optval == date[i].curmon) {                 sel = "selected";             } else {                 sel = "";             }             result = '<option value=' + data[i].optval + '' + sel + '>' + data[i].opt + '</option>';         });         $('#getmon').append(result);     } }); 

the value attribute should in quotes, more importantly you'll need space between , selected attribute.


Comments

Popular posts from this blog

powershell Start-Process exit code -1073741502 when used with Credential from a windows service environment -

twig - Using Twigbridge in a Laravel 5.1 Package -

c# - LINQ join Entities from HashSet's, Join vs Dictionary vs HashSet performance -