Dynamic loading of geotargeting content multifield

Avatar

Avatar

viki1101

Avatar

viki1101

viki1101

21-06-2020

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.

Accepted Solutions (1)

Accepted Solutions (1)

Avatar

Avatar

kautuk_sahni

Community Manager

Total Posts

5.5K

Likes

959

Correct Answer

1.1K

Avatar

kautuk_sahni

Community Manager

Total Posts

5.5K

Likes

959

Correct Answer

1.1K
kautuk_sahni
Community Manager

23-06-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)
    {
 
    }
});

Answers (0)