0

How to parse this generated json:

[{"Key":"template_1","Value":"\r\n<div class=\"box\">....</div>"}]
{"id":"8xxxxx-xxxxx-xxxx2","name":"Default","template":{"body":"<html>....</html>","width":210,"height":297}}

First should be a list with all templates (template_1, template_2..) and second is curent active template. 2nd need to grab it for edit if there's nothing active already.

Using this function to get from 2 different locations.

function getTemplates(url,id){
    var output = []
    $.post(url,{
            type:'templates',
        }, function(data){
            $.each(data, function(theme, val){
output.push(val);
            });
        });
        return output;
    }
}
getTemplates('/GetAll')
getTemplates('/invoiceprofilebyid?id='+pageId, pageId)
//pageId = 8xxxxx-xxxxx-xxxx2

Both returns empty array.

Adrian
  • 491
  • 6
  • 23

0 Answers0