Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

JavaScript Forum


You are currently viewing our JavaScript Forum as a guest. Please register to participate.
Login



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

Posts: 17
Trades: 0
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!
 
 
Register now for full access!
Old 12-13-2007, 06:50 AM Re: AJAX problem
chrishirst's Avatar
Missing! presumed drunk.

Posts: 41,517
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
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!! <<-
A foolish consistency is the hobgoblin of little minds
Thought for today:- I SEO the only industry where all the cowboys are Indians?
chrishirst is offline
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 12-13-2007, 07:45 PM Re: AJAX problem
handofra's Avatar
Average Talker

Posts: 17
Trades: 0
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
Missing! presumed drunk.

Posts: 41,517
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
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!! <<-
A foolish consistency is the hobgoblin of little minds
Thought for today:- I SEO the only industry where all the cowboys are Indians?
chrishirst is offline
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 12-14-2007, 08:28 PM Re: AJAX problem
handofra's Avatar
Average Talker

Posts: 17
Trades: 0
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
WT Moderator

Posts: 1,712
Name: Jeremy Miller
Location: Las Vegas, NV
Trades: 0
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

Please login or register to view this content. Registration is FREE
JeremyMiller is offline
Reply With Quote
View Public Profile Visit JeremyMiller's homepage!
 
Reply     « Reply to AJAX problem
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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

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





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



Page generated in 0.97329 seconds with 12 queries