PDA

View Full Version : How to use Javascripts in AJAX ??



racevthme
07-29-2008, 04:31 AM
My friend said me that the output of an AJAX page is plain html

I used tab in my webpage using


http://www.dynamicdrive.com/dynamicindex17/ajaxtabscontent/index.htm

but i cany use any of those javascripts inside those pages....

Someone help me please in this matter.

Jesdisciple
07-29-2008, 05:05 AM
What problem are you having? If possible, please post a live example URL. Your above post leaves us with absolutely no way to help you.

jscheuer1
07-29-2008, 05:43 AM
The simple way would be to use the script's iframe method to load pages with javascript on them.

racevthme
07-29-2008, 06:33 AM
I am using tabs in my page, i mean AJAX tabs to view external pages into this current page . But actually whats happening is my External pages have JavaScripts inside them.These are not functioning when viewed from the main page. People asked me to use iframes instead of AJAX tabs. But Is there any way to continue with AJAX instead of iframes but still enable teh javascripts

thanking you

Jesdisciple
07-29-2008, 07:23 AM
I can think of a way, but it uses kinda heavy PHP. (See "Advanced escaping" at http://www.php.net/manual/en/language.basic-syntax.php.)
<?php
$ajax = isset($_REQUEST['ajax']) && $_REQUEST['ajax'] == 'true';
if($ajax){
?>
<html>
<head>
...
</head>
<body>
Anything that repeats across pages or shouldn't be received by AJAX for some other reason.
<?php
}
?>
All the stuff you want to send whether AJAX is being used or not.
<?php
if($ajax){
?>
</body>
</html>
<?php
}
?>Now when you request that page, add ajax=true to the query string (for either GET or POST).

guif
07-29-2008, 07:25 AM
i have the same problem. When I open an html into a <div> content, if the html have a javascript code it's not run. why?
here is an example:
Enter to http://www.guif.net/menu/hola.html (this is a correct screen)
..And now, go to http://www.guif.net/menu/_index.html > Menú (at right, top) and click to the first link.
wow! the hola.html file is not correctly! Why????

Jesdisciple
07-29-2008, 07:40 AM
Hmm, I apparently misunderstood the OP. I thought he was complaining that the head tag shouldn't be included.

I think this is due to the youth of AJAX - browsers haven't fully adapted to it. But have you tried receiving the JS as a separate file and eval'ing it?

guif
07-29-2008, 11:18 AM
this is an answer for me?
I think that my problem is that the DIV don't open a javascripts files because if I open directly the file it's open correctly....

jscheuer1
07-29-2008, 12:19 PM
Ahem . . .


The simple way would be to use the script's iframe method to load pages with javascript on them.