Jump to content

Need Script to Run Upon Reloading Page via AJAX


drayarms

Recommended Posts

Hello people, my problem may sound a little unnecessary, but you guys must bare with me, I'm trying to create this really cool site with lots of special effects and I'm literally pushing the envelope. I'll simply describe the problem, showing the code isn't all that necessary.

 

The site in question has a menu bar, which loads the various pages associated with each menu item by making an AJAX call, when the menu item is clicked and not by making the usual trip to the server and waiting for the new page to load.  So basically, only the unique content of each page is loaded, while the header and footer remains static.

 

As soon as I accomplished that, I immediately realized that I had created a new problem.  Like I said, the site is supposed to be filled with lots of j Query special effects.  I'm currently working on some sliding effect on the homepage which is called with a document ready function. So when the homepage loads, the effect nicely runs on my screen. Well if I load another page, by clicking on its corresponding menu item, then decide to go back to the home page (by clicking home), the static markup on the homepage loads quite alright, but the dynamic elements, controlled by the j Query document ready function don't.  Of course I understand why this is the case, but how can I remedy this? I have tried to replace the document ready function with a named function called load, then call that function with an onload event in the div that contains the content for the homepage,  like this:

 

	<script type = "text/javascript">


	function load() {


	$("#slide1").animate({width: "toggle"}, '5000').delay(4000).animate({width: "toggle"},'5000');



	}    

 

<div onload = "load">  content unique to the homepage ...</div>

 

That didn't work.  I also tried this:

 

<div onload ="	$(\"#slide1\").animate({width: \"toggle\"}, '5000').delay(4000).animate({width: \"toggle\"},'5000');"> content unique to the homepage...</div>

 

Also to no avail. Any suggestions greatly welcome.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.