The function of search data is unavailable after published

I wrote a piece of code to display the search result from database and it worked when I tried it in preview mode. But after I published the site and tried to search it again, it was just blank. I have synchronized the sandbox and Live database already. The code shouldn’t have problems since I find it in the official tutorial and I worked when I test it in the preview mode. I just get confused why I could search data in preview mode but not after published. It doesn’t make sense! Can anyone help me fix it? Thanks a lot!

This image shows that I worked when I search in the preview mode.


This image shows that it doesn’t work after published.

The code is:
import wixData from ‘wix-data’;

$w.onReady( function () {
$w(“#table1”).hide();

});

export function button1_onclick(event) {
$w(“#table1”).show();
wixData.query(‘Order’)
.contains(‘email’, $w(‘#input1’).value)
.find()
.then((results) =>{
$w(‘#table1’).rows = results.items;
});
}

Hi!

Did you make sure that all of the selector names are matching to the ones of the components ID’s?
(For example - the table ID is ‘table1’)

If thats not the case, please share a link to your site so one of us, the WixCode team, can inspect it and provide you with a solution.

Doron.