Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

169
Visualizações
Python dictionary in jQuery

I've an ajax call in my html of a django application. How can I handle the returned object in javaScript if my python backend returns a list that includes python dictionary:

html:

$.ajax({
        type: "GET",
        url: '/api/check_variable/?name='+$("#foo").val()+'&stat='+stat_id,
        data: "check",
        success: function(response){
            alert("response[2]);
        } 
)}   

urls.py:

    urlpatterns = [
        path("check_variable/", views.api_for_class_checking, name="check_variable"),
    ]   
    

views.py:

    def api_for_class_checking(request, **kwargs):
        
        return ['id1', 'id2',{'filabel': 'label F', 'svlabel': 'labelS', 'enlabel': 'labelEn'}]     

In this case my html page alerts just Object as response[2]. How can I get the attributes of the returned object, like the value of 'filabel' e.g. ?

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

There is nothing wrong to your code because your ajax call returned an object:

{'filabel': 'label F', 'svlabel': 'labelS', 'enlabel': 'labelEn'}

If you want to alert an attribute of your returned data(for example: filabel) you can try this in your ajax call:

alert(`${response[2].filabel}`); 

Or,

alert(`${response[2]["filabel"]}`); 
about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda