JSON on page load
Hello Community - I have a property that is having a JSON value in the page's jcr:content. Basically, I wanted to load the JSON on the page load. Can someone provide the best approach to load the JSON?
Hello Community - I have a property that is having a JSON value in the page's jcr:content. Basically, I wanted to load the JSON on the page load. Can someone provide the best approach to load the JSON?
Hi @v1101 ,
you can write a servlet and in that you can call a particular node using resource api.
Once you got the node as a resource, it is very easy to read particular property of that node using value map.
Now you can call the servlet on page load using jquery.
Please see below for sample code.
Resource resource = resolver.getResource("/content/sita/en_UK/x/y/jcr:content/");
$.ajax({
type: 'GET',
url:'/bin/sitea/servleta',
processData: false,
contentType: false,
data:formData,
success: function(msg){
alert("json");
}
});
}
Thanks,
Sandeep.
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.