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
BedrockMission!

Learn more

View all

Sign in to view all badges

SOLVED

Ajax call to USE-API script

PremIB
Level 2
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.

ajax RTE use api
1 Accepted Solution
Arun_Patidar
Correct answer by
Community Advisor
Community Advisor
5 Replies
Arun_Patidar
Correct answer by
Community Advisor
Community Advisor
PremIB
Level 2
Level 2
@Arun_Patidar 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?
shelly-goel
Community Advisor
Community 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.

PremIB
Level 2
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?
shelly-goel
Community Advisor
Community 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.