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

George H. Compton IV replied to George H. Compton IV's discussion TIP Ning2 - Sub-tab down arrow for your navigation
"Thank you for the compliment JFarrow. :)"
1 hour ago
JFarrow replied to George H. Compton IV's discussion TIP Ning2 - Sub-tab down arrow for your navigation
"sweet work and great idea George!"
2 hours ago
Luke Jones replied to George H. Compton IV's discussion TIP Ning2 - Sub-tab down arrow for your navigation
":) that's fair enough aha :)I'm going stick with testing it on scratchpad for now,until I have more…"
3 hours ago
George H. Compton IV replied to George H. Compton IV's discussion TIP Ning2 - Sub-tab down arrow for your navigation
"A lot of the codes I right are customizing Ning's pages and their HTML, I'm not going to copy their…"
4 hours ago
Luke Jones replied to George H. Compton IV's discussion TIP Ning2 - Sub-tab down arrow for your navigation
"Ah right :) Well I prefer to write the code on Scratchpad first, to make sure I've got it right, I…"
4 hours ago
George H. Compton IV replied to George H. Compton IV's discussion TIP Ning2 - Sub-tab down arrow for your navigation
"Thank you lorianne  :)"
4 hours ago
George H. Compton IV replied to George H. Compton IV's discussion TIP Ning2 - Sub-tab down arrow for your navigation
"Luke I prefer to write codes on the network it's intended for that way I won't have to readjust the…"
4 hours ago
lorianne replied to George H. Compton IV's discussion TIP Ning2 - Sub-tab down arrow for your navigation
"i agree George, it is pretty!"
5 hours ago
Luke Jones replied to George H. Compton IV's discussion TIP Ning2 - Sub-tab down arrow for your navigation
"Aha poop sorry George lol, :P Aha fair enough lol :P Ah right :) , and you George :) 
well I know y…"
5 hours ago
George H. Compton IV replied to George H. Compton IV's discussion TIP Ning2 - Sub-tab down arrow for your navigation
"Hi lorianne
I've also done it that way but with my code you can style it anyway you want with any i…"
5 hours ago
George H. Compton IV replied to George H. Compton IV's discussion TIP Ning2 - Sub-tab down arrow for your navigation
"Thank you Luke. But my name is George. :-) LOL I don't use a program I use my brain and a test netw…"
5 hours ago
lorianne replied to George H. Compton IV's discussion TIP Ning2 - Sub-tab down arrow for your navigation
"i did this on my page to indicate sub-tabs were present by placing this ▼ when i created &  named t…"
5 hours ago
Luke Jones replied to George H. Compton IV's discussion TIP Ning2 - Sub-tab down arrow for your navigation
"That's cool John :) You always do awesome updates :) you and John are the ones that we need to hire…"
6 hours ago
Philip Voice replied to Luke Jones's discussion I would recommend Comet chat to anyone :)
"I want it on the chatbar. I want the main room to pop up right next to the who's online box."
9 hours ago
Bertalan Ecaterina left a comment for Bertalan Ecaterina
"Segitséget kérem  kataning.ning.com   webhelyen  mp3   5 Mb alatt sem engedi betölteni az anyagot,…"
9 hours ago
Kos replied to Luke Jones's discussion I would recommend Comet chat to anyone :)
"I have tons of things on diff. websites where images are "linked" to pages or diff. things.  It sav…"
9 hours ago
Strumelia replied to Luke Jones's discussion I would recommend Comet chat to anyone :)
"Isn't the new update for Cometchat all about just that?- inserting CC onto its own page rather than…"
10 hours ago
Strumelia replied to Luke Jones's discussion I would recommend Comet chat to anyone :)
"Nope, there's a line of Ning creators ahead of me in queue, currently migrating to Jamroom...I have…"
10 hours ago
Anam replied to Luke Jones's discussion I would recommend Comet chat to anyone :)
"That is an interesting idea Kos..I never thought of doing that. Maybe I will set to nervously tinke…"
10 hours ago
SweetPotato replied to Luke Jones's discussion I would recommend Comet chat to anyone :)
"Not left yet? :-)"
10 hours ago
More…