pp-before-request
The pp-before-request
attribute is used to target only the PHP function and the target element, without triggering a full page rendering. It is commonly used to update specific elements on the page without reloading the entire page, such as updating a shopping cart or displaying real-time notifications.
The pp-before-request="JSfunction"
attribute can be a string or a direct JavaScript function that represents the name of the function to be executed before the PHP function is triggered. Alternatively, you can use the pp-before-request="welcomeModal.showModal()"
attribute to show a modal before the PHP function is executed.
Example Usage
<?php
function handlerClick()
{
// Do something
}
?>
<button onclick="handlerClick" pp-before-request="handlerUIFront">Valid</button>
<script>
function handlerUIFront() {
// Do something
}
</script>
Note: The onclick
attribute is used to trigger the PHP function, while the pp-before-request
attribute is used to target only the JavaScript function. This attribute allows the JavaScript function to execute before the PHP function is triggered.