Hi All,
Can someone please tell me where am I going wrong I can not get the Json string from servlet. At servlet everything prints out as it should.
while (rs.next()) {
userObj = new User();
userObj.setClientId(Integer.parseInt(rs.getString(1)));
userObj.setClientName(rs.getString(2));
option.put(rs.getString(1), rs.getString(2)); //Map
json = new Gson().toJson(option);
response.setContentType("application/json");
response.setCharacterEncoding("UTF-8");
response.getWriter().write(json);
}
request.setAttribute("option", json);
request.getRequestDispatcher("/quickPwdReset.jsp").forward(request, response);
$(document).ready(function() {
$('#box1').on('change', function() {
clientId = $('option:selected', this).val();
$.get('PassUsers?id='+ clientId +'', function(responseJson) {
var $select = $('#box2');
$select.find('option').remove();
$.each(responseJson, function(key, value) {
$('<option>').val(key).text(value).appendTo($select);
});
});
});
});
<select id="box2" name="musrId" required="required" style="width:400px;">
<option></option>
</select>