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

125
Visualizações
Extract JSON response from jquery ajax to html div

I could not retrieve data to jquery div element but i can see ajax response in firebug.

$(document).ready(function () {
    $.ajax({
        url: "https://m.lowes.com/CatalogServices/product/nvalue/v1_0?nValue=4294857975&maxResults=6&showURL=1&rollUpVariants=1&showUrl=true&storeNumber=0595&priceFlag=rangeBalance&showMarketingBullets=1&callback",
        dataType: "jsonp",
        success: function (data) {
            var returnedData = JSON.parse(data);
            $('#result').html(returnedData);
        }
    });
})

this is my response.for example my url contains data productCount:64 ,I should extract productCount from ajax success and display it in html div id result

about 4 years ago · Santiago Trujillo
3 Respostas
Responde à pergunta

0

When you parse out the JSOn data you use it like so:

var parsed_data = JSON.parse(JSON_DATA);
$('#result').html(parsed_data.key);

So if your parsed_data is somewhat like:

{name:"test",age:12}

then you use it like:

$('#result').html(parsed_data.name); //it will give you test

if you really want to print out the whole data use JSON.stringify(obj) like so:

$('#result').html(JSON.stringify(parsed_data));
about 4 years ago · Santiago Trujillo Relatório

0

In your code you are returning a json and you are trying to insert ino the div it, into the div you can only insert html code instead json.

Try to inspect the json you are returning and in case you need to insert each element into the div, do it, but don't do for all.

The html() method doesn't know what you want to assign, it only insert an html.

about 4 years ago · Santiago Trujillo Relatório

0

You need to iterate over your json data in returnData. You are not able to put json directy into html. You need to convert / parse / iterate it before. So, for example:

$.each(returnedData, function (index, value) {
    // do stuff with it, e. g.:
    //  $('#result').html($('#result').html() + value);
});
about 4 years ago · Santiago Trujillo 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