Expand my Community achievements bar.

Dive into Adobe Summit 2024! Explore curated list of AEM sessions & labs, register, connect with experts, ask questions, engage, and share insights. Don't miss the excitement.
SOLVED

Ajax call to USE-API script

Avatar

Level 2

I have an RTE in my dialog with a link plugin, that would update some values data-foo & data-bar and store them along as part of the anchor tag in a property on save. data-foo and data-bar are completely dependent upon the href value mentioned by user in the link dialog. To generate both the values, I have a logic built using a use-api script that has access to the ResourceResolver and Externalizer classes. Is it possible for us to send an ajax call or any other request to the server with the href value as argument from the dialog.

Topics

Topics help categorize Community content and increase your ability to discover relevant content.

1 Accepted Solution

Avatar

Correct answer by
Community Advisor
5 Replies

Avatar

Correct answer by
Community Advisor

Avatar

Level 2
@arunpatidar but the use api script i've mentioned in is a javascript use api script. It also accepts some values as arguments. is it possible to execute this javascript use api script from a servlet then?

Avatar

Employee Advisor

@PremIB  Did you try to make this ajax call from the same use-api script where you're creating data-foo & data-bar? That should have the href value already.

Avatar

Level 2
@shelly-goel I do not understand why I should be making a call from the use-api script again to the same script. My intention here is to call the backend script from frontend javascript. is it possible?

Avatar

Employee Advisor
@PremIB - Yes you would be able to make an ajax call to a servlet at server side but not the Java use-api (I initially understood that you're using javascript use-api). The other option is you can get the richtext using getProperties().get("title", "") in the wcmusepojo extension and then parse it for all the href in it. Otherwise using javascript use-api could be an option too.