Help please!
This is what I got so far. Why is it not refreshing?
import wixData from 'wix-data';
import wixUsers from 'wix-users';
import wixLocation from 'wix-location';
$w.onReady(function(){
const currentUser = wixUsers.currentUser;
if (currentUser.loggedIn) {
currentUser.getEmail().then(email => {
wixData.query('Afiliados').eq('email', email).find()
.then(result => {
const item = result.items[0];
$w('#html1').src = item.title;
setTimeout(function(){
wixLocation.title.reload(1);
}, 5000);
});
});
}
});
Por favor, tente explicar seu problema em inglês.
bom dia pessoal, sou totalmente iniciante nisto e estou querendo um help com esse mesmo assunto, estou a 3 dias pesquisando e nao faço a menos ideia como atulaizar automaticamente apenas o a planilha google incorporada no site, alguem pode me ajudar? whats: 13 992037575
Brooooooo!!!! It finally worked, I just changed the field type to "URL", it was set to "Text". Thank you sooooooo much, I couldn't have done it without your help.!!
Yes, I'm sure it is a valid URL. I know so because, like I said before, the corresponding page loads up fine but it is after refreshing that I'm taken to this google drive page telling me some file is unable to open even though it is a URL that's being fetched not a file. Also I tried a different URL that had nothing to do with google and it just takes me to a blank page after refreshing. I already tried "console.log(item.title);" and it's still doing the same thing. :( What a bummer!
Are you sure "item.title" is a valid url?
Maybe try adding "console.log(item.title);" after setting the iframe url and share here what you get in console.
People, this has not been resolved. Any suggestions?
The corresponding page loaded but after refreshing I was taken to this google drive page.
This is what I have:
import wixData from 'wix-data';
import wixUsers from 'wix-users';
$w.onReady(function(){
const currentUser = wixUsers.currentUser;
if (currentUser.loggedIn) {
currentUser.getEmail().then(email => {
wixData.query('Afiliados').eq('email', email).find()
.then(result => {
const item = result.items[0];
$w('#html1').src = item.title;
setInterval(function(){
$w('#html1').src = item.title + '?' + Date.now();
}, 5000);
});
});
}
});
Try using:
$w('#html1').src = item.title + '?' + Date.now();
The added parameter shouldn't have en effect on the actual loaded page but the browser will think it's a different page and will not cache it.
I'm sorry I do not know how to do that, I'm a beginner. A lot of this is really confusing and I'd never done coding in my life. I already tried all kinds of different codes and combinations and I can't get this iframe to refresh. So how do you append a random string? :(
Maybe it's a matter of cache?
Try appending a random string (such as Date.now()) using a query string to the IFrame to see if it helps.
I used setInterval instead and it still not doing anything. The url loads but it's not refreshing. I don't know why it isn't working, it doesn't give me any errors and the code seems fine. :( FML
I see.
In this case, you should use setInterval. As opposed to setTimeout, it is repeating until clearInterval() is called.
The iframe is not reloading. I need to refresh it every 3 minutes actually, I just said 5 seconds because at first I wasn't sure how often it would need to be refreshed. The url is a web page version of a google spreadsheet and I want to refresh it periodically because different users will be inputing information constantly so I need to display all that information "live" as it is entered. I know the code looks fine but for some reason it's not refreshing the iframe. :( Help!
Code looks good. What exactly isn't working for you?
Also, why do you need to refresh the iframe every 5 seconds?
This is what I got so far, I don't understand what I'm doing wrong....
import wixData from 'wix-data';
import wixUsers from 'wix-users';
$w.onReady(function(){
const currentUser = wixUsers.currentUser;
if (currentUser.loggedIn) {
currentUser.getEmail().then(email => {
wixData.query('Afiliados').eq('email', email).find()
.then(result => {
const item = result.items[0];
$w('#html1').src = item.title;
setTimeout(function(){
$w('#html1').src = item.title;
}, 5000);
});
});
}
});
Still not working and I already tried all sorts of different combinations,
If you want to refresh the iframe every 5 seconds, you need to put that code in the setTimeout. Something like this:
setTimeout(function(){ $w('#html1').src = item.title; }, 5000);
It's refreshing the entire page not just the iframe. :(
Hey,
Please try using this code to reload:
wixLocation.to(wixLocation.url);