I have a problem using Jquery.
I do this:
$("#ID_ESTADO").change(function() {
document.getElementById("inprogress").style.visibility = "visible";
document.getElementById("ID_CERTIFICADO").setAttribute("disabled", true);
var url = '<%= Url.Content("~/") %>' + 'Certificado/ObtenerCertificados/';
$.getJSON(url + $("#ID_TIPO_POLIZA").val() + "/" + $("#ID_POLIZA").val() + "/" + $("#ID_ESTADO").val(), null, function(data) {
$("select[id$=ID_CERTIFICADO] > option").remove();
$.each(data, function(index, item) {
$("< option > ").attr("value", item.IDCertificado).text(item.IDCertificado).appendTo("#ID_CERTIFICADO");
});
document.getElementById("inprogress").style.visibility = "hidden";
document.getElementById("ID_CERTIFICADO").removeAttribute("disabled");
});
});
Code Behind:
Function ObtenerCertificados(ByVal parID1 As Long, ByVal parID2 As Long, ByVal parID3 As Long) As ActionResult
Dim varResultado As JsonResult = Nothing
Dim varCertificados As IEnumerable(Of CertificadosVehiculos) = varServicio.ListarCertificados(parID1, parID2, parID3, True)
Dim varJsonCertificados As IEnumerable(Of CertificadosVehiculos) = From vari In varCertificados Select New CertificadosVehiculos With {.IDCertificado = vari.IDCertificado}
varResultado = Json(varJsonCertificados.ToList())
varResultado.JsonRequestBehavior = JsonRequestBehavior.AllowGet
Return varResultado
End Function
If I change the dropdownlist ID_ESTADO then the dropdownlist ID_CERTIFICADO loads again. Sometimes this works perfectly, but when codebehind (varResultado) has many results (sometimes 3000) the lines inside jquery function doesn't run (I mean this lines):
$("select[id$=ID_CERTIFICADO] > option").remove();
$.each(data, function(index, item) {
$("< option >").attr("value", item.IDCertificado).text(item.IDCertificado).appendTo("#ID_CERTIFICADO");
});
I'm using jquery 1.4.2 and I tried with 1.4.1. I hope you can help me solving this. In CSharp o VB it's good the response. Sorry about my english.