Forum Moderators: open
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......
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.
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.
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?
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.
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.
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.
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!
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!
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 codeso 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! ;)
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!
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.
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.
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.
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.