Current status of the Ning Platform is always available on the Ning Status Blog.

Forum

Can you complete this code?

Hello Creators, I have a little challenge for those of you who know how to use the javascript language!

This is a code that apparently reloads only part of the page... anything that has an id. So, I have content on my network, ready to be refreshed every 5 minutes. I have wrapped my content in a <DIV>

this is how I did that...

<div id="#partialreload">

my content...

</div>

so, as far as I know, the content ready to be refreshed is now named with an id of #partialreload.

right?

So, here is the code that I am talking about, that should autorefresh the <DIV> that I have named, #partialreload.

its not working, I'm not really sure what I'm doing wrong. Can somebody offer a little bit of direction with this feature?

Thank you kindly!

Here's the codes...

$('#button1').click(function() 
{ var url = "http:www.your-url.com?ID=" + Math.random();
//create random number
setTimeout(function() { $("#elementName").load(url+" #elementName>*","");
}, 1000);

//wait one second to run function });

You need to be a member of Ning Creators Network to add comments!

Join Ning Creators Network

Email me when people reply –

Replies

  • What I do is put the part of your page that you want refreshed every few seconds on it's own page of a separate server. Then place this code below into the head of that page.

    I then iframe that page onto the whichever page you want.

    btw- I'm not a coder but I copy & paste well. Somebody I'm sure has a cleaner code:

    <script>
    <!--

    /*
    Auto Refresh Page with Time script
    By JavaScript Kit (javascriptkit.com)
    Over 200+ free scripts here!
    */

    //enter refresh time in "minutes:seconds" Minutes should range from 0 to inifinity. Seconds should range from 0 to 59
    var limit="0:02"

    if (document.images){
    var parselimit=limit.split(":")
    parselimit=parselimit[0]*60+parselimit[1]*1
    }
    function beginrefresh(){
    if (!document.images)
    return
    if (parselimit==1)
    window.location.reload()
    else{
    parselimit-=1
    curmin=Math.floor(parselimit/60)
    cursec=parselimit%60
    if (curmin!=0)
    curtime=curmin+" minutes and "+cursec+" seconds left until page refresh!"
    else
    curtime=cursec+" seconds left until page refresh!"
    window.status=curtime
    setTimeout("beginrefresh()",1000)
    }
    }

    window.onload=beginrefresh
    //-->
    </script>

    • Very interesting. I'm reading your code here, seems like that would do the trick... where would I put in my #partialreload <DIV> declaration though? That's the question. I wrapped the content I want to reload in a <DIV> called #partialreload.

      • I don't know the coding. Found it doing a google search, copied & pasted it.

        Make a new blank page using a different server, placed the html of the content you want to be refreshed every 2 seconds within the body tags then place that script in the head tag. Then give the page a name: /example-page.html

        Then go to the page you want the the content to be, and at the location of where you want it make an iframe <iframe src="/example-page.html" width="100%" height="135" scrolling="no" frameborder="0"></iframe> (adjust the height & width accordingly)

        • Oh also, if you have links in the content of your /example-page.html you'll want to target them with _parent.

  • NC for Hire

    Hi,

    first of all you cannot put # inside the ID tag of html.

    <div id="#partialreload"></div>

    Is ##partialreload

    Use this:

    <div id="partialreload"></div>

     

    While for the script:

    <script type="text/javascript">

    window.onload = refresher;

    function refresher(){
    setTimeout('refreshdiv();',300000);//refresh every 5 minutes , 5min =300000 milliseconds
    }
    function refreshdiv(){

    var url = "http://yoururl?id=" + Math.random();

    x$('#partialreload').load(url +" #elementname");

    }

    </script>

This reply was deleted.

Search the Creators Network

Latest Activity

Kos replied to Tat Ruck's discussion I can't edit text boxes?
"Sounds like a ticket will be needed on that"
4 minutes ago
Stelios Karavias replied to Nancy Marsh's discussion Not able to add video from TED Talks
"Are you sure your editor is turned to html when you embed the code?"
9 minutes ago
Stelios Karavias replied to Nancy Marsh's discussion Not able to add video from TED Talks
"This is strange. I just scanned our videos and found that one embed is from Ted and it works as a…"
11 minutes ago
Stelios Karavias replied to Tat Ruck's discussion I can't edit text boxes?
"Thank you Kos. Also CTRL+Shift+R also did the trick in Chrome. But there is another problem that…"
42 minutes ago
Kos replied to Tat Ruck's discussion I can't edit text boxes?
"Stellos said the hard refresh in Firefox worked for him.  If you need to file a ticket but…"
47 minutes ago
Stelios Karavias replied to Tat Ruck's discussion I can't edit text boxes?
"I had the same problem (Firefox and Chrome). A hard refresh in Firefox worked for me. I can now use…"
51 minutes ago
Tat Ruck replied to Tat Ruck's discussion I can't edit text boxes?
"Thanks Kos - tried this but still nothing - I think there is something wrong at the platform end…"
1 hour ago
Kos replied to Robert Paul's discussion buttons to change the text fields have disappeared on my first page
"Try to clear your browsers cache and if that doesn't work, try a hard refresh. …"
1 hour ago
Kos replied to Tat Ruck's discussion I can't edit text boxes?
"Clear the cache in your browser and if that doesn't do the trick, do a hard refresh. …"
1 hour ago
Kos replied to Nancy Marsh's discussion Not able to add video from TED Talks
"I completely agree.  I recommend you open a ticket and point this out - ask them to add TED as…"
1 hour ago
Mike Collins replied to Tat Ruck's discussion I can't edit text boxes?
"Raised a ticket on this"
1 hour ago
Tat Ruck replied to Tat Ruck's discussion I can't edit text boxes?
"Can you submit a ticket too Mike - they might look at it quicker if they get a few creators…"
3 hours ago
TJ @ jQueryHelp replied to Thomas Peet's discussion embedding photo thumbnails vs full album
"Thanks for the link!  I visited your site and I am able to see the Photo Albums without being…"
3 hours ago
Mike Collins replied to Tat Ruck's discussion I can't edit text boxes?
"Same here :("
3 hours ago
Robert Paul replied to Tat Ruck's discussion I can't edit text boxes?
"Finally i have ask a ticket now"
4 hours ago
Robert Paul replied to Tat Ruck's discussion I can't edit text boxes?
"No, I have not sent a ticket. If the problem is not resolved tomorrow, I will also send a ticjet"
4 hours ago
Tat Ruck replied to Tat Ruck's discussion I can't edit text boxes?
"Hmm, very frustrating.  Have you sent in a ticket too?"
4 hours ago
Robert Paul replied to Tat Ruck's discussion I can't edit text boxes?
"i have exactly the same problem (chrome)"
4 hours ago
Mike Collins replied to Nancy Marsh's discussion Not able to add video from TED Talks
"This could be a big issue for educational sites like ours where resouces  like TED Talks play…"
5 hours ago
NC for Hire Bernard Lama replied to Vander NG's discussion Content Sharing to Facebook
"Hi Vander, this feature is already available in NING 3.0 Go…"
7 hours ago