Allows you to define and call backend functions from the frontend.
In this example, we use web modules to define and export web methods. Web methods wrap backend functions which allows them to be called asynchronously from the frontend and adds a permissions check on the caller of your function.
We added the following to our site:
The code in this file enables site visitors to call a web method that sends a greeting as a response. In this file, we:
Defined a call count.
Added an onClick event handler to the Call backend function button that:
Calls a web method to retrieve a random greeting, specifying the call count.
Increments the call count by 1.
Displays the web method's response.
The code in this file enables site visitors to call 1 of 3 web methods that sends a greeting as a response. Each web method requires different permissions.
In this file, we added an onClick event handler to each button that:
Calls a web method. Each button calls a web method with different permissions.
If the site visitor has the required permissions, the site displays the web method's response.
If the call to the web method fails, the site displays an error message.
Join the Wix Studio community on Discord, where experienced developers and fellow creators come together to share tips, troubleshoot issues, and collaborate.
Building a coded solution on your own can be challenging. Let an experienced Wix developer build it for you, so you can keep working on your site or business. Visit the Wix Marketplace to find a trusted developer.