I use the following code to set the success message
if (data.success) {
<?php page()->setSuccessMessage("Created Successfully.") ?>
window.location.href = "login";
} else {
showError(el.newpin, data.message || "Failed to create.");
}
The code is working correctly but I want to know that is there any built in js function to set the success message from the javascript without using the php code inside the javascript.
when I use ew.alert("Your success message goes here ...", "success");
It popup a message for few 1 or 2 seconds and redirected to the login page as I am using window.location.href = "login";
but I want same work flow of the page()->setSuccessMessage("Created Successfully.")
as this will display the message in the login page.