Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

Adobe Summit 2023 [19th to 23rd March, Las Vegas and Virtual] | Complete AEM Session & Lab list

Querying from Javascript Use-API helper


Level 5

I have a search component built in sightly that I want to use to query on a number of parameters associated to find news articles (which are simply cq:pages) in our content repository. I know how I would do this with the Java Use-API, but want to use the javascript api in this particular case (partly because I'm trying to learn how t he JS API works).

In a similar component built years ago, I used a jquery.ajax() call to /bin/querybuilder.json, however, I can't figure out how to include jquery successfully in my code (I can include the jquery dependency ok, but get an error when trying to call on the jQuery object). Additionally, I'm not sure if this is even the best thing to do--that perhaps some javascript implementation of the querybuilder is exposed through a generally available variable.

Any guidance is appreciated.

4 Replies


Level 4
You cannot use JQuery inside JS Use API. That's server side javascript and you are very limited in what libraries you can use.


Level 5

Ok, that makes sense. I'm trying to find more documentation on the JS USE-Api, if anyone can point me in the right direction, I'd appreciate it.



Level 3

Hi All,

I am looking for a similar kind of functionality, but looks like Sightly JS Use APi only works on server side scripting. Even though I have included JQuery clientlibs, it still shows 'Reference error : '$' not defined'. Is there any way, we can make an ajax call in Sightly JS file?

Kindly note that this is for creating a JavaScript Object 'Data Layer' for holding meta data information about the website, which then will be tracked in Reports & Analytics.

I need to populate JSO(Data Layer) by making an ajax call to Sling Servlet for dynamically fetching user profile and other web site related information on page load.  I have been using JSP file for creating a JSO, but was thinking if we can leverage Javascript use api instead of using JSPs. Also, I am not sure if this is the right way to create a Data Layer in AEM 6.2. Please correct me if I am doing it in a wrong way.

Apperciate your help!



The ultimate experience is back.

Join us in Vegas to build skills, learn from the world's top brands, and be inspired.

Register Now