Fórum Problemas para carregar XML em combobox com jquery #408599
19/10/2011
0
<html xmlns=http://www.w3.org/1999/xhtml>
<head runat=server>
<title>A pagina Teste</title>
<script type=text/javascript src=js/jquery-1.6.4.js></script>
<script type=text/javascript>
$(document).ready(function() {
$.ajax({
type:GET,
URL:estados.xml,
dataType:xml,
success:function(xml){
var select = $(#idSelect);
$(xml).find(estado).each(function(){
var title = $(this).find(title).text();
var id = $(this).find(id).text();
console.log(Valor:[+id+] - - - label:[+title+]);
select.append(<option value=+id+> +title+</option>);
});
}
});
});
</script>
</head>
<body>
<form>
<select id=idSelect>
<option>Carregando..</option>
</select>
</form>
</body>
</html>
Código XML
<?xml version=1.0 encoding=iso-8859-1 ?> - <estados> - <estado> <title>RJ</title> <id>1</id> </estado> - <estado> <title>SP</title> <id>2</id> </estado> - <estado> <title>ES</title> <id>3</id> </estado> - <estado> <title>RG</title> <id>4</id> </estado> - <estado> <title>BA</title> <id>5</id> </estado> </estados>
Alan Miranda
Curtir tópico
+ 0Posts
24/10/2011
Alan Miranda
Eu consegui carregar a primeira combo, mas eu queria fazer um combo encadeada..
Gostei + 0
25/10/2011
Alan Miranda
Gostei + 0
26/10/2011
Alan Miranda
Gostei + 0
26/10/2011
Rodrigo Odasaki
Veja se ajuda:
http://dotnetspidor.blogspot.com/2009/04/bind-aspnet-dropdownlist-to-xml-file.html
Gostei + 0
27/10/2011
Alan Miranda
Então esse é com utilizando C#
Estou utilizando Jquery XML
Obrigado!
Gostei + 0
30/10/2011
Alan Miranda
Gostei + 0
01/11/2011
Alan Miranda
Gostei + 0
08/11/2011
Victor Fructuoso
Gostei + 0
Clique aqui para fazer login e interagir na Comunidade :)