Ich möchte JSON-Daten analysieren, die ich von URL in Lenker bekommen. Was ich versuchte, ist, dass ich die JSON-Daten von der URL bekam. Ich habe es in Datenobjekt definiert. Ich möchte wissen, wie kann ich die Daten analysieren mit lenker.js Ich bin neu zu lenker.js Gibt es eine andere Möglichkeit, in der wir bekommen können, ohne jede Eigenschaft zu definieren? Weil meine JSON-Daten riesig sind. für zB.JSON-Daten von URL erhalten wird nicht in lenker.js analysiert
reportData = {
inquiryId= data.data[0].inquiryId;
}
HTML-Code:
<script id="address-template" type="text/x-handlebars-template">
{{#with data}}
<p> My id is {{{inquiryId}}}</p>
{{/with}}
</script>
<div class="content-placeholder"></div>
JS-Code:
var reportData= {};
$(document).ready(function() {
$.ajax({
type:'GET',
url: reportURL,
success : function (data){
var inquiryId= data.data[0].inquiryId;
var theTemplateScript = $("#address-template").html();
console.log(theTemplateScript);
// Compile the template
var theTemplate = Handlebars.compile(theTemplateScript);
// Define our data object
reportData=data;
console.log(reportData);
// Pass our data to the template
var theCompiledHtml = theTemplate(reportData);
// Add the compiled html to the page
$('.content-placeholder').html(theCompiledHtml);
}
})
});
JSON:
{
"success":true,
"errors":{
},
"authenticated":true,
"program":1,
"data":[
{
"id":1,
"date":1505756267000,
"name":"AKKAYA, JORGE",
"productName":"Credit Profile",
"inquiryId":726608
}
]
}
Meine Ausgabe ist: Meine ID ist
Kann mir jemand helfen? Vielen Dank im Voraus.