Without using Javascript

Changing text on a page without page refresh?

Posted 08 June 2009 - 07:11 PM

Hi all

I am a complete PHP noob and whilst I have done some HTML and CSS, I am not even sure if PHP is the best way of doing what I want to do. I am also not sure of the correct way of phrasing what I am trying to do, so unsurprisingly, I haven't found anything in the forums or on the web.

As hinted at in the above code, when one of the unordered list items is clicked, it should update the body text below, either with a couple of paragraphs of text stored in a variable in the page, or maybe stored in a separate text file, I don't mind which.

My biggest aim is not to need a page refresh to update the text, followed closely by not using Javascript.

Re: Changing text on a page without page refresh?

It can't be done in PHP because the user doesn't see anything until PHP is done executing. Changes on the client end need to be done with client side software.

Why are you against using Javascript? (Personally, I think it's used too often and in unsafe ways, but it does have its uses.)

Thanks for all the replies. I was trying to stay away from Javascript because the kind of user who is going to be looking at the site in question is going to be un-tech-savvy. This means (probably) one of two 'profiles' - the clueless "default settings" brigade and the "ohmigod the intarwebs going to eat my computer" brigade who turn security settings up to maximum 'because its safer'.

The former don't pose a problem, but anyone who has javascript disabled would be a problem... which I had assumed happens when you turn security up to max in IE. Have I got the wrong end of the script... I mean stick?

Re: Changing text on a page without page refresh?

Posted 09 June 2009 - 06:56 AM

You could use CSS and a lot of relative/absolute positioning and some other tricks to pull this off but by far the easiest way is to use Javascript ... I have grown fond of JQuery it has a lot of very useful functions already built into it for ease of use ...

The CSS method is doable ... just takes a lot of working and position hacking for IE to make it look smooth and the same across all browsers ...

Re: Changing text on a page without page refresh?

The CSS method is doable ... just takes a lot of working and position hacking for IE to make it look smooth and the same across all browsers ...

Hmmm okay, I will look elsewhere as I don't need to make this a learning Odyssey!

CTphpnwb, on 9 Jun, 2009 - 06:12 AM, said:

Well, if you're going to code for the worst browser and the most xenophobic users out there, your site isn't going to be very good.

Ha! Better avoid that then

CTphpnwb, on 9 Jun, 2009 - 06:12 AM, said:

I think all web developers should go in the opposite direction: test for IE and point those users to standards compliant web browsers.

Unfortunately, I don't think the person I am writing the site for will want me to be bringing my soapbox out at this point

RPGonzo, on 9 Jun, 2009 - 05:56 AM, said:

You could use CSS and a lot of relative/absolute positioning and some other tricks to pull this off but by far the easiest way is to use Javascript ... I have grown fond of JQuery it has a lot of very useful functions already built into it for ease of use ...

Okay, I will check it out - thanks for the pointer

I will have to investigate JS and JQuery and see what will involve the least hassle - thanks everyone for very useful and incredibly quick replies. I really like DiC!

Core, on 8 Jun, 2009 - 07:08 PM, said:

You are probably looking for AJAX (Asynchronous Javascript And XML), but again, you will have to use Javascript. You won't be able to achieve this by using plain PHP.

Re: Changing text on a page without page refresh?

Posted 09 June 2009 - 07:33 AM

jw2k_fr, on 9 Jun, 2009 - 10:21 AM, said:

Unfortunately, I don't think the person I am writing the site for will want me to be bringing my soapbox out at this point

You could tone it down a little and simply suggest that their browsing experience would be better with a standards compliant browser. The reverse has been done for years, with many sites encouraging people to use IE. I got a notice just the other day while on vonage.com that warned me not to "upgrade" to IE 8 because their site wasn't yet compatible. That felt very much like a soapbox to me considering that I'm on a Mac.

Re: Changing text on a page without page refresh?

Posted 09 June 2009 - 07:47 AM

+1 IE sucks ... lol one one of my more casual gaming websites i have in the lower corner "Your IE browser sucks please don't use it k thx! UPGRADE NOW!" and it includes a link to FF but only if they are using IE of course ...

But back on topic the JQuery has a built in AJAX feature ... they have a all the documentation on their site of course