Dynamic loading of geotargeting content multifield | Community
Skip to main content
Level 5
June 22, 2020
Solved

Dynamic loading of geotargeting content multifield

  • June 22, 2020
  • 2 replies
  • 1220 views

Hello - 

This requirement is in Prod website and not in Author instance.

 

there is a dynamic component in the page. On selection of the state drop down, The content needs to be refreshed/changed according to the selection. The component is basically a Multifield component with reference/path to the content fragment Path/variation for each state. In the JCR node level of the page, we capture only the content fragment path and states, and not the actual content of the CF. 

 

Whenever I change the state, I have to refresh the browser to see the updated content. I am looking for ways to dynamically change the content based on selection.

I know this can be done via AJAX, can someone provide some light on this or any other way. Any samples will be greatly helpful.

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by kautuk_sahni
Reply from rajas66269496 

Here, the AJAX will workout, I don't see any other option because at JCR level you are saving node path not the CF content. you must hit a request to the path to get the content.

If you save CF content, then you can load in the every state CF content on the page in the hidden div's and based on the  state selection you can hide or show the content ( which I feel making things more complex )

You can use below  sample JQuery

$.ajax({
    url : "CF_PATH",
    type: "GET",
    data : formData,
    success: function(data, textStatus, jqXHR)
    {
        //replace the div content with the response
    },
    error: function (jqXHR, textStatus, errorThrown)
    {
 
    }
});

2 replies

raj_mandalapu
Level 7
June 22, 2020

When we change the dropdown we need to refresh the entire page to reflect the changes or we need to refresh only the fragment,

Here, the AJAX will workout, I don't see any other option because at JCR level you are saving node path not the CF content. you must hit a request to the path to get the content.

If you save CF content, then you can load in the every state CF content on the page in the hidden div's and based on the  state selection you can hide or show the content ( which I feel making things more complex )

You can use below  sample JQuery

$.ajax({
    url : "CF_PATH",
    type: "GET",
    data : formData,
    success: function(data, textStatus, jqXHR)
    {
        //replace the div content with the response
    },
    error: function (jqXHR, textStatus, errorThrown)
    {
 
    }
});

 

 

kautuk_sahni
Community Manager
kautuk_sahniCommunity ManagerAccepted solution
Community Manager
June 23, 2020
Reply from rajas66269496 

Here, the AJAX will workout, I don't see any other option because at JCR level you are saving node path not the CF content. you must hit a request to the path to get the content.

If you save CF content, then you can load in the every state CF content on the page in the hidden div's and based on the  state selection you can hide or show the content ( which I feel making things more complex )

You can use below  sample JQuery

$.ajax({
    url : "CF_PATH",
    type: "GET",
    data : formData,
    success: function(data, textStatus, jqXHR)
    {
        //replace the div content with the response
    },
    error: function (jqXHR, textStatus, errorThrown)
    {
 
    }
});
Kautuk Sahni