Hi I am trying to populate a combobox using ajax, but I cant get it work. This is my code, I get the data from a Servlet.
$.ajax({
type: "POST",
url: "../../sListarProvincia",
data: dataString,
success: function (data) {
$("#cboProvincia").append(data);
},
error: function (data) {
alert("ocurrio un error");
}
});
Here is the code on my Servlet.
try {
/* TODO output your page here. You may use following sample code. */
String IdDepartamento = request.getParameter("IdDepartamento").toString();
List<Ubigeo> lisUbigeo = UbigeoCOM.ListarProvincias(IdDepartamento);
String html="";
for(int i=0;i<lisUbigeo.size();i++)
{
html = html + "<option value="+lisUbigeo.get(i).getIdUbigeo()+">"+ lisUbigeo.get(i).getNombre()+"</option>";
}
out.println(html);
My html:
<select style="float:left" id="cboProvincia" class="combobox" name="cboDepartamento">
</select>