473,386 Members | 1,720 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Reload page asynchronously using Prototype

pezholio
Hi,

I'm currently putting together a stylesheet switcher for a project I'm working on, it's a server side solution at the moment, and I'd like to AJAX it up and avoid page reloads. I'm using Prototype's Ajax.Request method like so:

Expand|Select|Wrap|Line Numbers
  1. function resizetext(size) {
  2. new Ajax.Request('resize.php', {method: 'get', parameters: {style: size} });
  3. }
  4.  
And all seems to work fine(ish). My only problem is that you have to reload the page before the stylesheet changes, I'm guessing I have to do something involving the onComplete callback, but what I'm not sure. The page in question is here:

http://www.ratemyplace.org.uk/newsite/

Any help you can offer would be great, I'm a bit of a JavaScript n00b and have tried to figure it out for myself, but I've hit a brick wall!
Jun 9 '08 #1
3 4324
acoder
16,027 Expert Mod 8TB
To change stylesheets, you don't need Ajax (though you could perhaps be generating something via a server-side script). Just change the link href (in the head which loads the CSS file) to point to another CSS file. An easy way is to give it an ID and reference it using document.getElementById().
Jun 9 '08 #2
Yeah, I'd rather do it server side if at all possible, otherwise I'm duplicating work. Any ideas?
Jun 10 '08 #3
acoder
16,027 Expert Mod 8TB
Ignore what I wrote above about changing the href (I was thinking of something else). Here's a good tutorial. Just set disabled to false for those that you want to enable and don't forget to set the title and rel attributes. If you have problems implementing this, post back here.
Jun 10 '08 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: STEPHEN GOODE | last post by:
I have a php script that dynamically creates images, reusing image files on the server to save space and clutter. The problem is described in the steps below: 1. User clicks on a button. 2....
4
by: David MacQuigg | last post by:
I'm going to be teaching EEs some basic Python using the first few chapters of Learning Python, 2nd ed. by Mark Lutz. The discussion on Reloading Modules starting on page 266 is confusing and I...
3
by: sentinel | last post by:
Hi all, I'm trying to reload a frame from a pop-up, but really cannot figure this out. Within my index.htm file, I make a link to call a pop-up frame with a javascript function that calls the...
0
by: inetmug | last post by:
Hello: I am using ASP.NET as our front end. I also have to interface to some legacy systems that use a callback mechanism. The legacy systems use callbacks (via CORBA) to communicate back to...
19
by: Darren | last post by:
I have a page that opens a popup window and within the window, some databse info is submitted and the window closes. It then refreshes the original window using window.opener.location.reload(). ...
4
by: N. Demos | last post by:
Hello, I'm learning ASP.NET, and am having a strange problem with some example code from the book I'm using. The code increments and displays the value stored in a session variable when the "Add"...
7
by: fh | last post by:
hello! I 've a found way to reload my page automatically every n seconde using this code Response.AppendHeader("Refresh", "4"); it works fine but I wish to do the same with only a part of my...
1
by: Christian Sengstock | last post by:
Hi all, i have a js application with several event handlers which i manage via prototype .bindAsEventListener. On normal page navigation ( link navigation ) i finish all events handlers...
14
by: =?Utf-8?B?UGF1bA==?= | last post by:
Hi I tried a google search but could not find anything. I am trying to cause one webpage to reload when a second web page is closed. The second webpage loads data into a session variable and when...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.