hello i finish my code but the " always realod when i click on it without my code works please help me how can i remove the fking realod
Hi,
If you use the buttons' default behavior it submits the form on click. To avoid this you can use the below code in the bottom of your page, after all core-js scripts includes:
// On document ready()
KTUtil.onDOMContentLoaded(function () {
const myBtn = document.querySelector("#myBtn");
myBtn.addEventListener("click", function (e) {
e.preventDefault();
});
});
why i can't share the code ?
so how i can add it here
<div class="form-group text-center">
<input type="hidden" name="token" value="<?=$_SESSION["token"] ?>"/>
<input type="submit" class="btn btn-primary" value="Mettre à jour"/>
</div>
that's the demo2 metrocnic file if you don't have i give you
Not the HTML code btw, just the event handler that you are trying to fix
If it is a form causing the problem, it's most likely that the default action is your pain.
When you submit a form the page reloads, so the server can process the information, if you don't want that behavior you need to add
preventDefault
on jQuery you can do something like
$("#formId").on("submit", function(e){
e.preventDefault;
---- your code
})
Can you share a little more information about your code?
Besides. Try adding e.preventDefault soon after the click