Javascript/AJAX Eval(), How to load JAVASCRIPT after AJAX is called!

I am using the following snippet here:

Basically, for example, I have a index.php and a page that loads with ajax. we'll call that one ajaxpage.php . When theres no javascript in that page, its fine, But if I do something like..

<script language="JavaScript">

what ends up happening is everything but  document.write("hello!"): is called. so the page thats left is only


But missing the any other additional HTML/PHP. But If I load up  ajaxpage.php. It will display properly, aka:


Basiclly, I'm trying to figure out how ajax can do this properly.

I've also tried to use a countdown script located here:

Which again works great if you load the ajaxpage.php directly, but if you do the index.php page that loads the ajaxpage.php file, the result is BLANK.. So I'm guessing there is an issue using EVAL here .. Any suggestions? Thanks!
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

What happens when you load the first ajaxpage.php without adding the snippet from the link? I am not surprised that you only get "hello!" with it, because calling document.write() anytime after the page has loaded overwrites what is originally on the page.

Also, please consider if there is any way to avoid loading JavaScript through AJAX. Ask yourself whether you really need AJAX for this, or if an iframe would do. This is because I would not be surprised if you ran into some very confusing problems by trying to emulate JavaScript parsing using eval().

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
VallerianiAuthor Commented:
Hm Thanks.

The issue is I need a REAL countdown timer on a page that updates every 60 seconds. it must countdown from 60 to 0 basiclly. However, most of the 'update content' is in the 'ajaxpage.php file'.. Not sure what I can do :\ It has to be 'real updates' without a refresh style update, which is quote a pain to do (For work, boss wanted 'live numbers' that don't refresh the whole page so it doesn't scroll away etc)

When I load it without adding the snippit, it works fine and dandy!
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.