Expand my Community achievements bar.

SOLVED

ajax call teaser page components.

Avatar

Level 2

We have component that makes jquery ajax call to load some json. This component is used in a teaser page. When I hit the teaser with teaser.html the ajax call happens and the json is rendered. But when this teaser is resolved via segmentation and when this loads the page then this ajax call does not happen. The rendered html has the <script> element where ajax call needs to happen.

Any ideas?

Regards

Rama.

1 Accepted Solution

Avatar

Correct answer by
Level 2

Sham, thanks for your quick attention. It turned out that we have to use CQ.shared.HTTP.get(url, function() {}); rather than juery.Ajax. The issue was to execute an another ajax call on a teaser load while the teaser itself was loaded via ajax. so the 2nd ajax call was not happening because after first ajax call to load the teaser the script tags on the teaser page were treated like txt rather than executable java script. But some how this went away if I use CQ get api rather than jquery ajax api.

Regards

Rama.

View solution in original post

2 Replies

Avatar

Level 10

   Most of the time the root cause seems to be with some custom javascript the way it gets loaded. Is the url of page publicly accessible? 

Avatar

Correct answer by
Level 2

Sham, thanks for your quick attention. It turned out that we have to use CQ.shared.HTTP.get(url, function() {}); rather than juery.Ajax. The issue was to execute an another ajax call on a teaser load while the teaser itself was loaded via ajax. so the 2nd ajax call was not happening because after first ajax call to load the teaser the script tags on the teaser page were treated like txt rather than executable java script. But some how this went away if I use CQ get api rather than jquery ajax api.

Regards

Rama.