Good evening friends !!!
I have a (Repository) file inASP
that stores my selects
to some dropdowns
, in this I have the function below that lists my UF's:
public function ListarUF()
dim sql
dim cmd
dim rs
dim nota
dim lista
dim i
sql = "SELECT * FROM UF ORDER BY UF"
set cmd = ObterCommand(sql)
set rs = cmd.Execute
i = 0
do while not rs.eof
if i > 0 then
lista = lista & "|" & rs("UF")
else
lista = rs("UF")
end if
i = i + 1
rs.moveNext
loop
rs.close
set rs = nothing
set cmd = nothing
db.close
ListarUF = lista
end function
2nd - I have another ASP file that mentions the above to fetch the function in question ListarUF()
as follows:
In the page header I enter the command below:
<!--#include file="Repositorios/RepositorioAsimov.asp"-->
Then I create the method below:
caso "listarUF"
set repositorio = new clsRepositorioAsimov
lista = repositorio.ListarUF()
if err.number = 0 then
Response.Write(lista)
else
Response.Write(err.Description)
end if
set lista = nothing
set repositorio = nothing
3rd - In the page I have to load Dropdown
I enter the code ajax
below:
function popularDropDownListUf() {
$("#uf").empty();
$("#uf").append("<option value='' selected></option>");
$.ajax({
type: "POST",
url: "ServiceAsimov.asp?metodo=listarUF",
cache: false,
dataType: "html",
async: false,
success: function (response) {
if (response != null) {
var lista = response.split("|");
$.each(lista, function (key, value) {
$("#uf").append("<option value='" + value + "'>" + value + "</option>");
})
}
},
error: function (xhr, options, error) {
alert(error);
$(".loading").fadeOut();
}
});
}
My problem is that I am not able to bring the Id
of UF
and the UF
acronym together, only the acronym for UF
is coming to me.
What am I doing wrong?