lundi 26 octobre 2015

How to get Response json data in for loop using javascript

Below listed is my json response. My purpose is to get this data in javascript. My firebug console shows below result. Please help me to get data in js.

{"ProfessionFile":[[{"id":34,"title_en":"CEO"}],[{"id":35,"title_en":"PM"}]]}

Alert shows "undefined" result JS

$(".tag-handler-ambition").ready(function () {
    $.get("/profession/file", {tagcategoryid: 3}, function (response) {
            for (var i = 0; i < response.ProfessionFile.length; i++) {
                alert(response.ProfessionFile[i].id);
                $(".tag-handler-ambition").after('<div id="filename-response_' + response.ProfessionFile[i].id + '"><a href="/profession/download/' + response.ProfessionFile[i].id + '">' + response.ProfessionFile[i].title_en + '.pdf</a></div>');
            }
    });
});



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire