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

I am using the following snippet here:

http://www.developersnippets.com/2009/05/20/evaluate-scripts-while-working-on-ajax-requests/

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..

HELLO THERE MATEY!<br>
<script language="JavaScript">
document.write("hello!<br>"):
</script>
OTHER STUFF AFTERWARDS

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

"hello!
"

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

"HELLO THERE MATEY!
hello!
OTHER STUFF AFTERWARDS"

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

I've also tried to use a countdown script located here: http://www.dynamicdrive.com/dynamicindex6/dhtmlcount.htm

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!
LVL 7
VallerianiAsked:
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.

ZylochCommented:
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().
0

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!
0
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
JavaScript

From novice to tech pro — start learning today.