Reply
AJAX problem
Old 12-13-2007, 02:01 AM AJAX problem
handofra's Avatar
Novice Talker

Posts: 9
Hey, I just joined this forum seeking help for some problem that's been annoying me recently.

So basically I have a php page with a div serving as the Ajax container. I have all the needed external javascripts listed in the page such as lightbox2 and sweetTitles. The first time I update the container with Ajax, the tooltips and stuff works just fine. However when I update the Ajax container to another page, the scripts doesn't work anymore.

I've tried having the loaded pages linking to the external javascript files on its own, however that doesn't work as well.

I hope you understand my problem, and help me with it soon.
Thanks!
handofra is offline
Reply With Quote
View Public Profile Visit handofra's homepage!
 
When You Register, These Ads Go Away!
Old 12-13-2007, 06:50 AM Re: AJAX problem
chrishirst's Avatar
Super Moderator

Posts: 15,216
Location: Blackpool. UK
This;
Quote:
However when I update the Ajax container to another page,
needs a bit of explanation. Update to another page?
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
Indifference will be the downfall of mankind, but who cares?
Code Samples | People Counting System
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 12-13-2007, 07:45 PM Re: AJAX problem
handofra's Avatar
Novice Talker

Posts: 9
Oops, I mean update the div content with Ajax to another page.
handofra is offline
Reply With Quote
View Public Profile Visit handofra's homepage!
 
Old 12-14-2007, 07:54 AM Re: AJAX problem
chrishirst's Avatar
Super Moderator

Posts: 15,216
Location: Blackpool. UK
What is probably happening and this is an educated guess, is that when the new content is rendered & parsed by the client browser, the existing methods and variables do not get reinitialised but are being set to nothing.

A test for this would be to reinitialise the javascripts on the return of the ajax call.
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
Indifference will be the downfall of mankind, but who cares?
Code Samples | People Counting System
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 12-14-2007, 08:28 PM Re: AJAX problem
handofra's Avatar
Novice Talker

Posts: 9
Ah yes, I was looking for a way to reload the external javascript inside the new loaded content. I sort of got sweetTitles and lightbox2 working inside the content by reinitializing the script inside the content...like this:

Code:
<script>EventCache.flush();pageLoader();initLightbox();</script>
If there is a more efficient way to reload the external scripts other than calling the init functions directly, please tell me.
handofra is offline
Reply With Quote
View Public Profile Visit handofra's homepage!
 
Old 12-15-2007, 12:45 AM Re: AJAX problem
JeremyMiller's Avatar
Full-Time TeraTasker

Posts: 1,003
Name: Jeremy Miller
Location: Reno, NV
I rather doubt that there's a more efficient means. If you "just" add javascript inside of <script> tags into a container as part of HTML via Ajax, the javascript is not parsed. For example, Google's Adsense code is not rendered if served via an Ajax script (unless you reparse it through the DOM which would be your equivalent of reinitializing scripts).
__________________
Jeremy Miller - TeraTask Technologies, LLC
Content Farmer - Automated Posting for Content & Blog Sites
JeremyMiller is offline
Reply With Quote
View Public Profile Visit JeremyMiller's homepage!
 
Reply     « Reply to AJAX problem
 

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off


Webmaster Resources Marketplace:
Software Development Company | Webhosting.UK.com | Text Link Brokers 


   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML

 


Page generated in 0.12966 seconds with 12 queries