Button to submit data, refresh database and refresh page

Problem Solved (sort of)

- To anyone who may be having a similiar issue, all I did was add a confirmation page so that after the user clicks the submit button, they were redirected to a confirmation page first and then back to the members area allowing for the members page to reload

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

- Does anyone know how I can make a button submit data to my database, refresh the database and refresh the page on click?

- Right now I have a button, button23 , that submits user data to a database and then returns to my Members Page on click. However, when it returns to the Members Page the data that was just submitted doesn’t show up until after I refresh the page manually

- I have tried codes provided to similiar questions on this forum and haven’t had any results. Any help is very much appreciated, thank you!

1 Like

if you have a dataset on your page you can call save() then call location.to to navigate to the page.
To make sure the item is ready before you navigate use the following method:

$w("#myDataset").save()
.then( (item) => {
  wixLocation.to("/somepage");
 } )
 .catch( (err) => { let errMsg = err; 
 } );

Try that code (worked fine for me)

import wixLocation from ‘wix-location’;
import wixWindow from ‘wix-window’;

$w.onReady( function () {
$w(‘#registerNow’).onClick( function () {
wixLocation.to(wixLocation.url);
wixWindow.lightbox.close(“lightbox1”);
})
})

To anyone looking to reload a page onSubmit, onClick, the following code worked for me:

import wixLocation from ‘wix-location’ ;
$w . onReady ( function () {
$w ( “#button390” ). onClick ( ( event ) => {
wixLocation . to ( wixLocation . url ); // refresh current page
});
});