Forum Moderators: open

Message Too Old, No Replies

Partial page refresh.

         

1simone

3:18 am on Apr 15, 2007 (gmt 0)

10+ Year Member



Its important I find a refresh to just one part of a page. Namely to refresh a div instead of a whole page. Anyone know what kind of scripting can cause a partial page refresh? Already googled nothing found yet. http request as far as I can tell pulls something into the div, thats not what I need. I just need the div itself refreshed so the server can read whats in it again without refreshing the whole page. Please let me know, thank you very much....

1simone

3:40 am on Apr 15, 2007 (gmt 0)

10+ Year Member



Forgot to say I don't need any buttons or hrefs to cause a refresh, I just need an automatic fresh after so much time.

Dabrowski

7:52 pm on Apr 15, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You can't refresh part of a page.

http request as far as I can tell pulls something into the div

Very likely, this is normally the way to add content onto the page.

server can read whats in it again

Really not sure what you mean by this, the server can't read the page, only by a form being submitted. The best way of refreshing the content of the DIV would be to use setInterval to repeat the httprequest every x seconds. Is this what you mean?

The syntax is:

setInterval( "myFunction();", 5000); // 5 seconds

Can you expand a little on what you have and what you're trying to achieve? There may be a better way......

1simone

2:54 am on Apr 16, 2007 (gmt 0)

10+ Year Member



Dabrowski, thanks for trying to help. I mean so that the server can read just part of the page instead of the whole thing. Just a small part that has some server side scripting in it. Will this allow the server to just read a div only?

setInterval( "myFunction();", 5000); // 5 seconds

What about this, this refreshes a whole page.
<BODY onLoad=window.setTimeout("location.href='http://www.website.com/page.html'",600000)>
Can you apply an onload to a div only? If so will whats in that div be read by the server?

If none of those work, couldn't I put some server side scripting into a form field and have that form field only refresh on a timer? So instead of the form being sent, instead it would just refresh? There must be a way somehow, I know all the big programmers are getting around this some way. Thanks.

daveVk

3:07 am on Apr 16, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Do site search (in banner above) for "load content into div"

Dabrowski

11:21 am on Apr 16, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



No, you can't assign an onload to a DIV.

Will this allow the server to just read a div only

I'm still confused by this, do you mean you'd like the BROWSER to refresh the contents of the DIV, which is looked up with httprequest from a SERVER?

The server doesn't read the browser, it's the other way around. Please tell me exactly what you're trying to do or I can't help you further.

1simone

2:43 am on Apr 17, 2007 (gmt 0)

10+ Year Member



I just want to refresh whats in a div or one one part of a page only, not the whole page. I can't make that any clearer.

So that the sever can read some sort of server side script on that part of the page only. What about putting the script into a form field, then on a timer the form only is sent to the server, only to come right back to appear on the page again?

Dabrowski

10:51 am on Apr 17, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Simone, I think you're confusing the issue. I assume your DIV is filled in by an AJAX lookup or somthing, and what you're really asking is how to repeat that?

Tell you what, send me a sticky with the web address on it so I can have a look at the page, cos without seeing the code I can't know what you're trying to do.

1simone

12:51 am on Apr 18, 2007 (gmt 0)

10+ Year Member



Dabrowski lol, I'm sorry but I haven't said I am using Ajax at all, I also haven't said I am trying to load anything into a div using Ajax. I don't have a page set up yet because I don't know how to proceed. I'm asking about finding a way to refresh a div with an ID or some other ID on the page. So that whatever is in that ID or Div will be rereshed only, not the whole page. Whatever is in that section of the page, a server side script. Whether the server side script is in the div, in a form field in a div, whatever. Just so the server can read whatever I put into that particular part of the page. But nothing needs to be loaded, the server side will just be sitting on the page, in the div, or in the form field, just waiting to be refreshed someway so the server can read it again. Nothing needs to be loaded into it, its already there. I appreciate very much your trying to help I can use it.

Dabrowski

1:37 am on Apr 18, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



LOL

Huh?

I haven't said I am using Ajax at all

No, you haven't really said anything that makes sense. I guessed at something that might give you a grain of knowledge.

I don't know how to proceed

So why won't you tell me what exactly, and I mean exactly, what you're trying to achieve.

I'm asking about finding a way to refresh a div

You don't refresh DIVs or any other elements. You can refresh the PAGE if you like.

So that whatever is in that ID or Div will be rereshed only

So you have to have dynamic content in there, I've been asking all along what it is or going to be.

Whatever is in that section of the page

Nope, it's all or nothing.

a server side script

Note the key words server side, means on the SERVER, not the CLIENT. i.e. generated when the client downloads the entire file, div and all.

Whether the server side script is in the div, in a form field in a div, whatever

Nope, server side script is on the server, not in the page. The server side script would generate the page.

Just so the server can read whatever I put into that particular part of the page

Again....wrong way around. Think of the word...server. It serves the page. The client reads it, the server doesn't give a f**k about the client.

But nothing needs to be loaded, the server side will just be sitting on the page, in the div, or in the form field

No it won't.

Nothing needs to be loaded into it, its already there

If it's already there then you need to load something into it for anything to change?

What planet are you on? You have almost everything backwards. The only right thing you have is that there is a server, a page and a div.

If you want any more help you either need to tell me exactly what you want to do, or have an actual problem, that consists of actual code that actually doesn't work, not just something that's actually made up.

I'm thinking of a lot of adjectives at the moment, guess which ones?

Seriously though, get back to me with a real problem or details of what you want and I can help. Otherwise I can't. I'm not a mind reader and despite repeatedly asking you still haven't told me anything definate.

daveVk

2:36 am on Apr 18, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



[webmasterworld.com...] think is this what you are trying to do?

1simone

5:58 am on Apr 18, 2007 (gmt 0)

10+ Year Member



Hey there Dave! Good to see you. Thanks for the help, I'll read up on it and check it out. Here's another one someone sent me in a private message that looks like a hopeful maybe as well [w3schools.com...]
because it utilizes the id's as well as a form. I'm not sure what will happen with this link I list because it wants to load something again, but I might be able to rig it somehow. But if anyone bumps into anything else please let me know. Best sent your way!

Dabrowski

10:46 am on Apr 18, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



1simone, that link you just posted uses "AJAX" and does a "HTTP request" to get the info for the DIV.

This is exactly what I suggested earler which you shrugged off. If this is similar to whatever it is you wish to achieve then yes it will work, and it's very easy to make it repeat once a minute or something.

Get an example working once, and then I'll gladly help you make it repeat. Send me a sticky.

1simone

1:58 am on Apr 20, 2007 (gmt 0)

10+ Year Member



I did not shrug it off, I am open to all suggestions, I said I didn't suggest ajax like you said I did.
Regarding httprequest as is, it won't work unfortunately either because I need to have the server read my code, then put it back again. Which I don't believe javascript will do, because when javascript puts it back it puts it back as javascript, not as the server side code anymore. But there might be some sort of another kind of ajax that might help me with what I need, I just haven't found it yet. So I was going to try to utilize just a part of that, but it won't work. But who do you think you are that you can be continually mean to me? Because you didn't understand what I want? Once again in your last reply you were mean again. This time you told me I shrugged you off before when I didn't, I just said I never said something like you said I did. You are imagining things that never happen and are also putting words in mouth saying I said things I never did. But then to boot you are cruel to me because of it. If you read through this whole thread you will see the one with the attitude is you. Well here's some of mine, how does it feel? If your not going to be nice to us, then don't help.

Dabrowski

9:11 am on Apr 20, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



you can be continually mean to me

Simone, I apologise if my previous posts seemed offensive, it wasn't intentional. More like sarcasm, and trying to make you think about the details of your problem.

Of course I am happy to help you, as others have helped me on the forum, I'm simply trying to understand what it is you're trying to achieve.

But that aside, lets try again....

I need to have the server read my code, then put it back again

I will stress again, you repeat the fact that you want your server to read your code? This will never, ever, ever happen. It's not the way it works.

I said I didn't suggest ajax like you said I did

I suggested AJAX httprequest as this is a common way of sending data to a server, and getting a HTML response, which seems like what you want. Note, data sent to server, not code. You could also use something as simple as posting data to your server through a hidden form, which you could manipulate with Javascript. You could even if you wanted to send it the HTML contents of your DIV, but this would make doing something with it on the server end very difficult, that's why you normally use a form and just send the data you want.

because when javascript puts it back it puts it back as javascript, not as the server side code anymore

If you add HTML code to your page, such as would be inside your DIV then this will be HTML. It can be proven by testing the contents of innerHTML, or getElementBySomething.

Server side code remains on the server. An example would be if you see an extension in a URL like .pl this is a server side language called Perl. The code you see on the page has been produced by that program, but is not that program's code.

I think I've given you just about every option, so I'm going to ask again, please please please tell me details about what you're trying to achieve so I can help and advise you the best way to proceed. I have lots of experience with server side scripting, and javascript. You obviously have an objective in mind, but if you don't elaborate on it I, nor anybody else can help you.

If you don't wish to post code here or reveal to the world what it is (I'm thinking herpes clinic? ;) ), then send me a stickymail with a web address on that I can look at.

Again, sorry if I offended you but I am really trying very hard to help. Don't be a stranger!

1simone

1:50 am on Apr 21, 2007 (gmt 0)

10+ Year Member



OK, thank you and you're very mature than most to respond nicely. Thanks for telling me you have experience in this and thank you very, very much for still offering to help me. All is definitely forgotten and you are a very nice and considerate person. ;)

I'll do the best I can to explain all of my thinking on this. Hoping you can make sense out of it. I don't know how to proceed with this which is why many things aren't nailed down. I'm just trying to tell people what I'm looking for to get some feedback.

What I meant by the javascript.... I didn't want the whole code to be javascript because the output of the code into html won't show in the source code. I need something where the output of the server side script can be seen in the source code, so some search engines can read the html. But if I put the code in a form I don't think most search engines can read that either. But if its the only way I'll do it and worry about the rest later, because they are coming up with new applications ever day.

If there is a way to put server side code into a div and have the server execute it somehow would be preferable, without page refreshes. Or if that for sure cannot be done, a form will have to do. I need it without page refreshes because the pages move too much with regular refreshes and what brought me here.

Hoping that clears up most of what my thinking is. The summary is that I need something that can let the server execute my server side code, so that its results can show on my pages and in my source code. Also so the server side code is just sitting there waiting to be executed again after so much time. Please let me know what your thoughts are on this. Thank you!

Dabrowski

10:27 am on Apr 21, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



are a very nice and considerate person

*blush*

ok, now you're making sense. What you want can't be done, but you have 2 scenarios here which are possible, let me explain.....

I didn't want the whole code to be javascript because the output of the code into html won't show in the source code

so some search engines can read the html. But if I put the code in a form I don't think most search engines can read that either

Right. Bang on.

If there is a way to put server side code into a div and have the server execute it somehow would be preferable, without page refreshes

Yes there is, no there isn't.

You have to choose one of 2 methods.

First: You have the server generate the entire code, this will ensure that search engines can read it so assuming you want it for SEO purposes this is the only way really. But you have to refresh the whole page.

Second: You use a page with a DIV that you can use JS to fill in later either directly or by calling in a page from the server. Your entire page won't refresh every time, just the part the server fills in, but the search engines can't read it.

Third: Just thought of this one....You could use an IFRAME to call in the server part instead of a DIV. That way you'd have 2 separate pages, one containing the IFRAME. Then the IFRAME could be refreshed on it's own, and the search engines could read the URL of the IFRAME in it's own right.

The only but with the third is that a spider won't read the IFRAME src tag, so on the containing page you'd have to have an A href for the spider to follow. Not an ideal solution.

ok, it's make your mind up time! ;)

1simone

12:15 am on Apr 22, 2007 (gmt 0)

10+ Year Member



LOL! I like your Right, bang on and so forth.

Well I don't give up easy so I'm going to research this in further detail, but I know what you mean about it looking pretty grim. I'll let you know if anything turns up.

Please tell me one more thing. What do you mean about the search engine following the a link? Please let me know, thanks!

1simone

1:28 am on Apr 22, 2007 (gmt 0)

10+ Year Member



Forgot to say I'm going to try to learn more about callbacks so that I can hopefully understand this all better.

daveVk

2:17 am on Apr 22, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Agree with Dabrowski. What you also need to consider is the nature and amount of the extra non static content, that is the content you intend to change on a periodic basis.

Design the page for users who have javascript disabled in mind, this is also how the search engines see your page.

Possible options for javascript disabled users may be
- include all extra content as part of of main page.
- include links to extra content, where each "extra" has its own page.
- dont show extra content at all.
- summary of each "extra" with/without link.
- others?

Having decided that, technical solutions will follow.

Dabrowski

10:16 am on Apr 22, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



looking pretty grim

I wouldn't say that, what you want it absolutely possible, just not quite in the way you want it.

What do you mean about the search engine following the a link

You mentioned before about search engines looking at the source of your site. That's correct, but to find all the pages they follow every link on the page, starting at your index page, or whichever page they get by looking at [yourdomain.com...]

Design the page for users who have javascript disabled in mind

Personally I don't care about these people. Most of my sites will work anyway without JS, more by luck that judgement.

But if you do care about these people you will certainly have to rule out options 2 and 3, and you wouldn't be able to do the automatic refresh.

So let's start with some details, what is the content that you want your server to produce, and how often will it need to be update? If you can tell me this then I can advise which is the best way to do it.

1simone

2:39 am on Apr 24, 2007 (gmt 0)

10+ Year Member



I'd probably put some sort of javascript must be enabled message or something because so many sites are using javascript on them now. Gosh Dobrowski hope I spelled that right, can't see your last post. Any sort of php or asp that outputs some html. Right now I'm looking at an html request and seeing if I can get it to repeat. I'm working on the timer right now, once I get that figured out then I guess I'll try hooking it up to a form or a div, but even if I don't hear back from you, thanks to you both for all your help!

Dabrowski

9:20 am on Apr 24, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I've actually been thinking about the JS disabled thing. The ongoing problem is that without JS, you can't trigger anything to say it's disabled.

However you can use a front page which specifically says 'You have JS disabled'. On that page write a script that uses location.replace to get to your real index page, put it in the <head>.

Then if they don't have JS, they'll get the error message, if they do it will redirect before the browser renders it.

Dabrowski

9:58 am on Apr 24, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I personally wouldn't worry about end users with JS disabled. I'm sure 99% of them don't know what it is, or that it exists, so won't turn it off.

If I was you I'd create a static HTML (or SHTML?) page with your DIV. You'd use JS with httprequest to call a PHP/Perl script on your server, which generated the content for your DIV.

Use setInterval to repeat this lookup on whatever timescale you like.

Try and get that working, and get back to us if you need any further help.

1simone

12:50 am on Apr 27, 2007 (gmt 0)

10+ Year Member



Thanks for all your help Dabrowski, I'll look into it!