Forum Discussion

iftomkins's avatar
11 years ago
Solved

How to run Freemarker code on click?

I have a bit of freemarker code which updates a user's profile fields: 

 

<#-- Call user click, set accepted terms -->
<#assign response = restadmin("/users/id/${user.id}/profiles/name/ideas_terms_accepted/set?value=checked")/>
<#assign response = restadmin("/users/id/${user.id}/profiles/name/ideas_terms_accepted_date/set?value=" + datesupport.millisecondsAsString)/>

 

When a user clicks "I accept terms and conditions", I want to run this freemarker code. How do I call this code on click?

 

I can put it in an Endpoint, but then how do I call that endpoint on click? I can put it in a Macro, but then how do I call that Macro on click?

 

Thanks!

Alan

  • JasonL's avatar
    JasonL
    11 years ago

    hi iftomkins 

    from the screenshot, i roughly guessed your Community :-)

     

    took a look at your endpoint, instead of

    <#return "test"?json_string />

    try this (since it's application/json - that's what you should be returning, the #return in freemarker is more for freemarker function calls)

    { "status": "ok" }

     

    the endpoint should work ... then the client-side ajax should be working too ... i hope